I also made this question before but the problems remains here:
I have this code:
<asp:Button ID="CrearCuenta" UseSubmitBehavior="false" OnClientClick="return validate()" runat="server" Text="Ready" />
The javascript code:
function validate()
{
return false;
}
But in case that it return true, how do i execute de server side onclick function?? Thats what i cannot figure out. I know that similars question have been posted before, but none answer the question above.
I also made this question before but the problems remains here:
I have this code:
<asp:Button ID="CrearCuenta" UseSubmitBehavior="false" OnClientClick="return validate()" runat="server" Text="Ready" />
The javascript code:
function validate()
{
return false;
}
But in case that it return true, how do i execute de server side onclick function?? Thats what i cannot figure out. I know that similars question have been posted before, but none answer the question above.
Share Improve this question asked Mar 4, 2013 at 13:59 MistersMisters 1,3472 gold badges16 silver badges30 bronze badges 5- Ive re-read this 5 times and still cant find a question. – BenjaminPaul Commented Mar 4, 2013 at 14:01
- Done, now its easier to find it – Misters Commented Mar 4, 2013 at 14:02
- 1 you need to add logic to validate function....otherwise submit will never work..... – A.T. Commented Mar 4, 2013 at 14:04
- It has it. it returns false if the validation fail. Ive tried athousands times and returns false if fails. So, whats the problem? – Misters Commented Mar 4, 2013 at 14:06
- @Arun you were right, i miss something and it wasnt retuning anything – Misters Commented Mar 4, 2013 at 14:18
3 Answers
Reset to default 5I hope, here is what you need:
<asp:Button ID="CrearCuenta" UseSubmitBehavior="false"
OnClientClick="return validate()" OnClick="CrearCuenta_Click"
runat="server" Text="Ready" />
Javascript:
function validate()
{
if()
return false; //if validation fails
else
return true;
}
Server Side:
protected void CrearCuenta_Click(object sender, EventArgs e)
{
//Put server side processing here
}
Have you added the server side event handler?
In your page code:
<asp:Button ID="CrearCuenta" OnClick="btn_Click"....
In your code-behind:
protected void btn_Click(object sender, EventArgs e)
{
....
}
check this code
document.getElementById('YourFrom').onsubmit = function() {
return false;
}