asp按钮onclick事件未触发 [英] asp button onclick event not firing
本文介绍了asp按钮onclick事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
asp按钮的onclick事件未触发,button(id ="submit")具有onclick事件(Submit_Click),该事件不会在单击时触发.为什么?
< form enctype ="multipart/form-data" method ="post" action ="javascript:;">< div class ="content">< p>我是回头客</p>< b>电子邮件地址:</b>< br/>< asp:TextBox名称=电子邮件" runat =服务器" ID =电子邮件"></asp:TextBox>< asp:RegularExpressionValidator ID ="email_validation" runat ="server"ControlToValidate =电子邮件" ErrorMessage =输入有效的电子邮件" ForeColor =红色"ValidationExpression ="\ w +([-+.'] \ w +)* @ \ w +([-.] \ w +)* \.\ w +([-.] \ w +)*"ValidationGroup ="email"></asp:RegularExpressionValidator>< br/>< br/>< b>密码:</b>< br/>< asp:TextBox runat =服务器" name =密码" TextMode =密码"></asp:TextBox>< br/>< a href ="javascript:;">忘记的密码</a>< br/>< br/>< asp:按钮ID =提交" runat =服务器" CssClass =按钮"文本=登录"onclick ="Submit_Click"/>< input type ="hidden" value ="http://www.przemyslawlobodzinski.pl/themes/megastore/index.php?route=account/account"name ="redirect"/></div></form>
解决方案
该表单缺少 runat = server
标记.
为使asp:Button触发服务器端事件,它必须采用设置了runat ="server"属性的形式.所有服务器控件都是如此.( http://www.w3schools.com/aspnet/aspnet_forms.asp )>
您的表单似乎正在尝试调用JavaScript.
asp button onclick event not firing, the button(id="submit") has a onclick event (Submit_Click) , which is not firing on click. why???
<form enctype="multipart/form-data" method="post" action="javascript:;">
<div class="content">
<p>
I am a returning customer</p>
<b>E-Mail Address:</b><br />
<asp:TextBox name="email" runat="server" ID="email"></asp:TextBox>
<asp:RegularExpressionValidator ID="email_validation" runat="server"
ControlToValidate="email" ErrorMessage="enter a valid email" ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="email"></asp:RegularExpressionValidator>
<br />
<br />
<b>Password:</b><br />
<asp:TextBox runat="server" name="password" TextMode="Password"></asp:TextBox>
<br />
<a href="javascript:;">Forgotten Password</a><br />
<br />
<asp:Button ID="Submit" runat="server" CssClass="button" Text="Login"
onclick="Submit_Click" />
<input type="hidden" value="http://www.przemyslawlobodzinski.pl/themes/megastore/index.php?route=account/account"
name="redirect"/>
</div>
</form>
解决方案
The form is missing the runat=server
tag.
For the asp:Button to trigger a server-side event, it needs to be in a form that has the runat="server" attribute set. This is true for all server controls. ( http://www.w3schools.com/aspnet/aspnet_forms.asp )
Your form seems to be trying to call JavaScript instead.
这篇关于asp按钮onclick事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文