3
I’ve been having the following problem:
I have a registration form in which the customer must enter his data through the Inputs, at the end there is a button of type Submit, and when clicking it would be triggered the event click to there to get the data. It turns out that by clicking on the Submit button it submits the form but does not execute my click event, follows a snippet of code:
aspx:
<form runat="server" name="sign">
<input runat="server" type="text" placeholder="Seu nome" ID="userName"/>
<br/>
<input runat="server" type="email" placeholder="Seu e-mail" ID="userEmail"/>
<br/>
<input runat="server" type="text" placeholder="Sua senha" ID="userPassword"/>
<br/>
<asp:Button runat="server" ID="sign" Text="Cadastrar" OnClick="sign"/>
</form
C# (Code Behind):
public partial class Index : System.Web.UI.Page
{
string userNm;
string userEml;
string userPass;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void sign(object sender, EventArgs e)
{
userNm = userName.Value;
userEml = userEmail.Value;
userPass = userPassword.Value;
}
}
You are using Webforms?
– Albertt Santos
Make sure that there is nothing preventing the button from firing, such as some validation. Try adding "Causesvalidation="false"" to the test button only.
– Leonardo Buta
But the Sign method of the event
OnClick
is server side... it will need to do a post to run on the server, you are not falling there? put a breakpoint?– Leandro Angelo