VBScript Issue in ASP.net page
I have a VBScript function in my ASP.net Page I have a small test function as shown below
<script 开发者_C百科type="text/vbscript">
sub testmePlease()
msgbox("Hello World")
end sub
</script>
I have a button in my webform and I am calling the function onclientclick as shown below
<asp:Button ID="btnAccept" runat="server" Text="Accept Settlement" OnClientClick="testmePlease()"/>
For some reason I get this end of statement expected javascipt error. What can be wrong??
I'm assuming you're using IE. Once Internet Explorer finds first <script>
tag in your page, it assumes it's language as default.
Try this:
<script type="text/javascript">var foobar = false;</script>
<script type="text/vbscript">
sub testmePlease()
msgbox("Hello World")
end sub
</script>
And change your button to:
<asp:Button ID="btnAccept" runat="server"
Text="Accept Settlement"
OnClientClick="return testmePlease()"/>
Everything else should run ok.
精彩评论