problem in calling a function according to condition specified
-
hello i m calling a javascript function on page load like...
Page.RegisterStartupScript("abs", "<script language=\"JavaScript\"> printAlert();</script>");
and my java script function is...
function printAlert()
{
var check=confirm("Do You Want To Print The Certificate");
print(check);
return check;
}function print(res) { var color; if(res==true) color= document.getElementById("<%=btnPrint.ClientID%>").bgColor="red"; }
and on page load i m calling another funtion like
if (btnPrint.BackColor.ToString() == "red") { myC#function(); }
</pre>
js function is working fine but on page load btnPrint.BackColor is always showing empty...so my c# function is never called.... please someone help
-
hello i m calling a javascript function on page load like...
Page.RegisterStartupScript("abs", "<script language=\"JavaScript\"> printAlert();</script>");
and my java script function is...
function printAlert()
{
var check=confirm("Do You Want To Print The Certificate");
print(check);
return check;
}function print(res) { var color; if(res==true) color= document.getElementById("<%=btnPrint.ClientID%>").bgColor="red"; }
and on page load i m calling another funtion like
if (btnPrint.BackColor.ToString() == "red") { myC#function(); }
</pre>
js function is working fine but on page load btnPrint.BackColor is always showing empty...so my c# function is never called.... please someone help
Have you stepped through using firebug/firefox to see if the js is doing what you expect it to ? Is bgColor the right property here ? Or is it blah.style.bgColor ? js just invents properties the first time you access them.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Have you stepped through using firebug/firefox to see if the js is doing what you expect it to ? Is bgColor the right property here ? Or is it blah.style.bgColor ? js just invents properties the first time you access them.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
when i m doing ok on confirm box it is showing red on alert(color); but my c# function is not calling...please help me....i have also tried through...
.style.backgroundColor="red";
it is changing the button's color but my motive is not to change the button's color....i want to call my c# function on basis of my condition...
if (btnPrint.BackColor.ToString() == "red")
{
myC#Function();
}but its not working... please help me
-
when i m doing ok on confirm box it is showing red on alert(color); but my c# function is not calling...please help me....i have also tried through...
.style.backgroundColor="red";
it is changing the button's color but my motive is not to change the button's color....i want to call my c# function on basis of my condition...
if (btnPrint.BackColor.ToString() == "red")
{
myC#Function();
}but its not working... please help me
If you do a postback, does it stay red ? If not, then the property is not stored in viewstate. If so, then I'd create a control and set the BackColor property in the aspx. Then I'd run the page, view the source, and see exactly what property ASP.NET is setting in the control. At the end of the day, I'd still lean towards using a hidden field.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
If you do a postback, does it stay red ? If not, then the property is not stored in viewstate. If so, then I'd create a control and set the BackColor property in the aspx. Then I'd run the page, view the source, and see exactly what property ASP.NET is setting in the control. At the end of the day, I'd still lean towards using a hidden field.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
my problem is still a problem....please someone help
-
my problem is still a problem....please someone help
I did. What happened when you did what I suggested ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I did. What happened when you did what I suggested ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
i tried that through hidden field....and on step by step debugging i checked that also...it is first compiling these lines...
if (btnPrint.Value.ToString() == "1")
{
myC#function();
}and after that javascript function so my c# function is never called please give me a solution
-
i tried that through hidden field....and on step by step debugging i checked that also...it is first compiling these lines...
if (btnPrint.Value.ToString() == "1")
{
myC#function();
}and after that javascript function so my c# function is never called please give me a solution
The solution is to debug your javascript - did you get Firebug and Firefox as I suggested ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
i tried that through hidden field....and on step by step debugging i checked that also...it is first compiling these lines...
if (btnPrint.Value.ToString() == "1")
{
myC#function();
}and after that javascript function so my c# function is never called please give me a solution
Hi I am sure what Gauss suggested is the way you must address the issue. Open your web page in Mozila FireFox ( this is just a browser like Internet Explorer but helps a lot for debugging Javascript error. ) and idntify which line of your JS code creates the problem !!!
Thanks, Arindam D Tewary