按钮onclick事件未在ASP .NET中触发 [英] Button onclick event not firing in ASP .NET

查看:70
本文介绍了按钮onclick事件未在ASP .NET中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述










  • Log In
  • Sign Up









欢迎回来!





< form method =post>

<% - < asp :Panel ID =panel1runat =server> - %>




Welcome Back!



<form method="post" >
<%-- <asp:Panel ID="panel1" runat="server">--%>



< asp:TextBox ID =txteml占位符=电子邮件地址runat =serverautocomplete =offrequired =>


<asp:TextBox ID="txteml" placeholder="Email Address" runat="server" autocomplete="off" required="">






< asp:TextBox ID =txtpasswordplaceholder =Passwordrunat = serverautocomplete =offrequired =TextMode =Password>


<asp:TextBox ID="txtpassword" placeholder="Password" runat="server" autocomplete="off" required="" TextMode="Password">





忘记密码?









<% - < asp:Panel ID =panel2runat =server> - %>

<% - < asp:Panel ID =signuprunat =serverstyle =display:none> - %>

免费注册



< form method =post>




<%-- <asp:Panel ID="panel2" runat="server">--%>
<%--<asp:Panel ID="signup" runat="server" style="display:none">--%>

Sign Up for Free


<form method="post">



< asp:TextBox ID =txtnmplaceholder =Namerunat =serverrequired =autocomplete =off>


<asp:TextBox ID="txtnm" placeholder="Name" runat="server" required="" autocomplete="off">






< asp:TextBox ID =txtemailplaceholder = 电子邮件地址runat =serverrequired =autocomplete =off>


<asp:TextBox ID="txtemail" placeholder="Email Address" runat="server" required="" autocomplete="off" >






< asp:TextBox ID =txtpassplaceholder = 设置密码runat =serverrequired =autocomplete =offTextMode =Password>


<asp:TextBox ID="txtpass" placeholder="Set A Password" runat="server" required="" autocomplete="off" TextMode="Password" >



< asp:Button ID =btnusersignrunat =serverText =submitOnClick =btnusersign_Clickclass =button- log button-block/>



< / form>

<% - - %>


<asp:Button ID="btnusersign" runat="server" Text="submit" OnClick="btnusersign_Click" class="button-log button-block" />

</form>
<%-- --%>




<! - tab-content - >



<!-- tab-content -->








<! - 开始页脚 - >





<!-- Start footer -->















< img src =AdminLTE-2.3.0 / assets / img / logo-white.pngalt =>

Lorem ipsum dolor sit amet,consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua。 Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris


<img src="AdminLTE-2.3.0/assets/img/logo-white.png" alt="">

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris

404,Mark Twain Tower,Saint MG Road,United States

404, Mark Twain Tower, Saint MG Road, United States












电子邮件简报



< form action =#>

< input type =textplaceholder =电子邮件地址>

< button type =submit> < / button>

< / form>

不要担心我们讨厌垃圾邮件!我们也保护您的电子邮件;)


Email Newsletters


<form action="#">
<input type="text" placeholder="Email Address">
<button type="submit"></button>
</form>

Don't worry we hate spam! we also protect your email ;)






























使用HTML5和CSS3构建版权所有©2015 BootExperts













  • FACEBOOK
  • GOOGLE PLUS
  • TWITTER
  • SERVICES
  • LINKEDIN

















<! - 结束页脚 - >

<! - JS - >









< script src =AdminLTE-2.3.0 / assets / js / jquery-1.11.3.min.js>< / script>

<! - jquery-1.11.3.min js

========================== === =============== - >





<! - bootstrap js

========================================== == - >

< script src =AdminLTE-2.3.0 / assets / js / bootstrap.min.js>< / script>



<! - jQuery REVOLUTION Slider - >

< script src =AdminLTE-2.3.0 / assets / js / jquery.themepunch.tools .min.js>< / script>

< script src =AdminLTE-2.3.0 / assets / js / jquery.themepunch.revolution.min.js>< / script>

< script src =AdminLTE-2.3.0 / assets / js / rs.home.js>< / script>







<! - jquery.sidr.min js

========= =================================== - >

< script src =AdminLTE-2.3.0 / assets / js / jquery.sidr.min.js>< / script>







<! - main js

============================================ - >

< script src =AdminLTE-2.3.0 / assets / js / main.js>< / script>



< ; - 登录 - >

< script src =AdminLTE-2.3.0 / assets / js / log.js>< / script>





< / form>



< / body>



我尝试了什么:



登录按钮正在运行,但提交按钮(注册)是不工作



<!-- End footer -->
<!-- JS -->




<script src="AdminLTE-2.3.0/assets/js/jquery-1.11.3.min.js"></script>
<!-- jquery-1.11.3.min js
============================================ -->


<!-- bootstrap js
============================================ -->
<script src="AdminLTE-2.3.0/assets/js/bootstrap.min.js"></script>

<!-- jQuery REVOLUTION Slider -->
<script src="AdminLTE-2.3.0/assets/js/jquery.themepunch.tools.min.js"></script>
<script src="AdminLTE-2.3.0/assets/js/jquery.themepunch.revolution.min.js"></script>
<script src="AdminLTE-2.3.0/assets/js/rs.home.js"></script>



<!-- jquery.sidr.min js
============================================ -->
<script src="AdminLTE-2.3.0/assets/js/jquery.sidr.min.js"></script>



<!-- main js
============================================ -->
<script src="AdminLTE-2.3.0/assets/js/main.js"></script>

<!-- log in -->
<script src="AdminLTE-2.3.0/assets/js/log.js"></script>


</form>

</body>

What I have tried:

login button is working but submit button(signup) is not working

推荐答案

如果您希望我们在您的问题上轻松帮助您,您需要明确说明。其次,请尝试格式化您的代码以使其更具可读性。



根据您的问题,您提到注册按钮未触发但我找不到该按钮在你的标记或我只是盲目的:)



你也在你的表单中使用服务器控件(例如ASP.NET TextBox),但你的表单不有一个runat =server属性分配给它。您的按钮登录是因为您将OnClick服务器事件连接到它而触发的。您的其他按钮属于提交类型,并且没有事件处理程序。单击提交类型的按钮将在您单击时提交表单。它不会触发onclick事件,但会触发load事件。更清楚这里是一个快速演示:



ASPX:

You need to make your statement clear if you want us to easily assist you on your issue. Second, please try to format your code to make more readable.

Down to your issue, You mentioned signup button isn't firing but I can't find that button in your markup or I am just blind :)

Also you are using a server controls (e.g ASP.NET TextBox) in your form, but your form doesn't have a runat="server" attribute assigned to it. Your button Login fired because you wired-up an OnClick server event to it. Your other Button is of type submit and doesn't have an event handler. Button with type "submit" will submit the form when you click on it. It doesn't fire an onclick event but it will fire the load event. Take make it more clear here's a quick demo:

ASPX:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="text" name="txt1" />
        <button type="submit">Submit Form!</button>
    </div>
    </form>
</body>
</html>





背后的代码:



CODE BEHIND:

using System;

namespace WebFormDemo
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e) {
            if (Request.Form["txt1"] != null) {
                var stringValue = Request.Form["txt1"];
            }
        }
    }
}





点击提交按钮即可执行POST,允许您从输入元素中获取已发布的值。



Clicking on the submit button will perform a POST and allowing you to get posted values from an input elements.


这篇关于按钮onclick事件未在ASP .NET中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆