Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript
hi friends,
 
i'm calling two javascript functions on button click after adding them on pageload
as follows:
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 1-Jun-12 2:32am
preet881.2K
Edited 1-Jun-12 2:36am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

//Keep as is simple
function Onclick()  {
    var b = btnClickValidation();
    if (b)
        btn();
    return b;
}
 
and then
 
btnSave.Attributes.Add("onclick", "return Onclick();");
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 .
 
btnSave.Attributes.Add("onclick", "var a=btnClickValidation(); if (a == true) {btn();} else { return false;}"); 
  Permalink  
Comments
Prosan at 1-Jun-12 8:27am
   
it will surely work tested. you can try this.
preet88 at 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)

  Print Answers RSS
0 OriginalGriff 200
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 1 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100