初学者问题,OnClientClick调用vbscript过程的简单的问题。
为什么网页会有错误!无法弹出msgbox!
<script  language="vbscript" type ="text/vbscript" >
function Test()
MsgBox ("one two")
End function
</script><html >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button ID="btnTest" runat="Server" Text="Test" OnClientClick="Test()" Visible="True" />
    </div>
    </form>
</body>
</html>这样却可以弹出窗口!<script language="javascript" type ="text/javascript" >
function Test(){
alert('Do you want to subscribe the thread?');
}
</script><html >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button ID="btnTest" runat="Server" Text="Test" OnClientClick="Test()" Visible="True" />
    </div>
    </form>
</body>
</html>谢谢!请详细说一下,我好困扰!

解决方案 »

  1.   

    try:
    function Test() 
    return MsgBox ("one two") 
    end function 
      

  2.   

    不行啊,朋友。页面提示
    行22 字符7 错误语句未结束 代码0 url:http//localhost:1031/website1/lx.aspx
    下面是页面代码<script language="vbscript" type ="text/vbscript" >
    function Test() 
    return MsgBox ("one two") 
    end function 
    </script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head><title>
    无标题页
    </title></head>
    <body>
        <form name="form1" method="post" action="lx.aspx" id="form1">
    <div>
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY3NzE5MjIyMGRkRukqIRyjX8QWIm0o/kBwS4K9CDc=" />
    </div>    <div>
        <input type="submit" name="btnTest" value="Test" onclick="Test();" id="btnTest" />
        </div>
        
    <div> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgK4vLnjBwK14deQBZlCNEM0A1ema0BC18I7EUIXaTk6" />
    </div></form>
    </body>
    </html>
      

  3.   

    MsgBox 和alert不就是弹出对话框吗?没有看明白lz的意思
      

  4.   

    Sorry,没有看清楚阿,哈哈VBScript应该也是可以的阿,我给看看
      

  5.   

    <script  language="vbscript" type ="text/vbscript" > 
    function Test() 
    return MsgBox ("one two") 
    end function 
    </script> 
     <asp:Button runat="server" ID="aa" OnClientClick="javascript:Test()" Text="aaa" />
      

  6.   

    MsgBox对话框 弹不出来
    alert对话框 可以弹出
    我想知道为什么
    谢谢
      

  7.   

    也不用return 了,OnClientClick="javascript:Test()"
      

  8.   

    sub Test()//your code here
    End Sub
      

  9.   

    CutBug 你好 你的代码可以 我想知道为什么加了javascript:Test() 就可以了
      

  10.   

    <script language="vbscript">
    sub show()
    MsgBox "欢迎阁下光临"
    end sub
    </script>
    <input type="button" value="确定" onclick="vbs:show()">
      

  11.   

    Teng_s2000你好 这段代码我调试不成功。
    CutBug的可以
    谢谢
      

  12.   

    我现在想知道<asp:Button runat="server" ID="aa" OnClientClick="javascript:Test()" Text="aaa" /> 为什么加了javascript:就可以了?
      

  13.   

    <input type="button" value="Test" onclick="Test()" /> 就没有问题!你可以在看看你的页面得到的html,在“Test()”后边有一个;号。asp.net本身其实不考虑vbscript,它对控件的事件处理代码一律是“javascript:”开头,和“;”结尾,这无法用于。按理说,如果它可以设置一个参数使得不在处理OnClientClick时最后多余地添加一个“;”就完全不会出错。
      

  14.   


    上面解释了,asp.net生成的代码都是javascript语法。你记得总是使用这个语法来调用vbscript函数就没有问题了。