in THE BELOW CODE OnClientClick not Firing plz Help me for this problem...
7 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sathish PabbathiPosted Apr 13, 2013, 12:04 AM
Sathish PabbathiPosted Apr 12, 2013, 6:35 AM
Vishal GilbilePosted Apr 12, 2013, 4:15 AM
if (txt1 ==0)
{
alert("plz fill the employe's First name!!");
}
with
if (txt1 =="" || txt1=="0")
{
alert("plz fill the employe's First name!!");
return false;
}
if(x==true)
return true;
else
return false;
Hope that helps you.
With Regards,
Vishal Gilbile.
Gaurav GuptaPosted Apr 12, 2013, 3:32 AM
And
Put the Code on the OnClientClick event...
OnClientClick ="return Confirm("Are sure want to add new Record ?:");"
Vishal GilbilePosted Apr 12, 2013, 3:12 AM
With Regards,
Vishal Gilbile.
Sathish PabbathiPosted Apr 12, 2013, 3:11 AM
Vishal GilbilePosted Apr 12, 2013, 2:59 AM
you should use return statement only when your function is returning any value. Well now whenever your function returns any value the syntax for calling the function on OnClintClick would be like the following.
Note: When you function returns value.
OnClientClick="javascript:return FunctionName()";
If your function is not returning any value you could easily call it like the following.
OnClientClick="FunctionName();"
Also for accessing the Server side control in your javascript code, the way of accessing is different.
For instance if you are writing this javascript code on your Child page Or Content Page
the way would be
var txtValue=document.getElementById('<%=txtEmpName.ClientID%>').value;
If your page is normal webpage i.e. no master page applied on it then the way for accessing server control would be like the following.
var txtValue=document.forms[0]["txtEmpName"].value;
Hope that solves your problem.
With Regards,
Vishal Gilbile.