问题描述
<scriptlanguage="javascript">functioncheack(){if(document.getElementById("TextBox1").value==""){alert("联系电话不能为空!");document.getElementById("TextBox1").focus();returnfalse;}if(document.getElementById("TextBox2").value==""){alert("22222222222");document.getElementById(TextBox2).focus();returnfalse;}if(document.getElementById("TextBox3").value==""){alert("ccccccccccccc");document.getElementById(TextBox3).focus();returnfalse;}returntrue;}functioncc(){document.getElementById("TextBox1").focus();}</script></HEAD><bodyMS_POSITIONING="GridLayout"onload="cc();"><formid="Form1"method="post"runat="server">联系电话<asp:TextBoxid="TextBox1"runat="server"></asp:TextBox>联系电话2<asp:TextBoxid="TextBox2"runat="server"></asp:TextBox>联系电话88<asp:TextBoxid="TextBox3"runat="server"></asp:TextBox><asp:Buttonid="Button1"runat="server"Text="Button"onclick="returncheack();"></asp:Button></form>我这样写他提示错误:CompilerErrorMessage:CS1041:Identifierexpected,'return'isakeywordSourceError:Line42:<asp:Buttonid="Button1"304px"runat="server"-------红色Line43:Text="Button"onclick="returncheack();"></asp:Button>
解决方案
解决方案二:
<formid="Form1"method="post"runat="server">联系电话<asp:TextBoxid="TextBox1"runat="server"></asp:TextBox>联系电话2<asp:TextBoxid="TextBox2"runat="server"></asp:TextBox>联系电话88<asp:TextBoxid="TextBox3"runat="server"></asp:TextBox><asp:Buttonid="Button1"runat="server"Text="Button"</form>后台.csprivatevoidButton1_Click(objectsender,System.EventArgse){this.Button1.Attributes.Add("onclick","returncheack();");Response.Write("dddddddddddddddddddddddddddddddddd");}这样的话他执行了Response.Write("dddddddddddddddddddddddddddddddddd");才返回(onclick)
解决方案三:
OnClientClick
解决方案四:
<asp:Buttonid="Button1"runat="server"Text="Button"OnClientClick="returncheack()"></asp:Button><scriptlanguage="javascript">functioncheack(){if(document.getElementById("TextBox1").value==""){alert("联系电话不能为空!");document.getElementById("TextBox1").focus();returnfalse;}if(document.getElementById("TextBox2").value==""){alert("22222222222");document.getElementById(TextBox2).focus();returnfalse;}if(document.getElementById("TextBox3").value==""){alert("ccccccccccccc");document.getElementById(TextBox3).focus();returnfalse;}returntrue;}</script>
解决方案五:
我用的是2003是不是没有这个事件functioncheack(){alert("asdfasdfsd");}<asp:Buttonid="Button1"runat="server"Text="Button"OnClientClick="returncheack()"></asp:Button>没反映
解决方案六:
用这样就可以了<inputid="Button2"type="button"value="button"onclick="returnCheck()"runat="server"/>
解决方案七:
45
解决方案八:
this.Button1.Attributes.Add("onclick","returncheack();");这个加到page——load()里面