Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
hi friends,

i'm calling two javascript functions on button click after adding them on pageload
as follows:
C#
btnSave.Attributes.Add("onclick", "return btnClickValidation();btn();"); 

here btnClickValidation(); returns either true or false.
and hence btn(); doesnot executes
however if I swap the calling order it works well..

Other thing that i want to do is I want to call the btn(); when postback happens... Is this possible? If yes Then how
Thanks in advance
Posted
Updated 1-Jun-12 1:36am
v3

C#
//Keep as is simple
function Onclick()  {
    var b = btnClickValidation();
    if (b)
        btn();
    return b;
}

and then

btnSave.Attributes.Add("onclick", "return Onclick();");
 
Share this answer
 
simply you can call the function btn in btnClickValidation() function because when we return than it will no go to your second js function btn or you can use it as .

C#
btnSave.Attributes.Add("onclick", "var a=btnClickValidation(); if (a == true) {btn();} else { return false;}"); 
 
Share this answer
 
Comments
Prosan 1-Jun-12 8:27am    
it will surely work tested. you can try this.
preet88 5-Jun-12 1:19am    
thanks i have done some similar kind of code in javascript itself thanks for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900