Craig Davis

Craig Davis

  • NA
  • 40
  • 0

Using javascript function in server side code behind

Mar 21 2011 1:25 PM
I have a good idea how to bind a javascript function to a asp.net web control such as a radio button using an attribute.add method in code behind (for example): 

protected void Page_Load(object sender, EventArgs e)

{


panel4radio1.Attributes.Add("onClick", "Hidecontrols()");

This is a great way to assign javascript functionality to my radio button.  This doesn't however actually execute the javascript.  I would like to do both - execute javascript such as hiding a label from the server side during a page load or another event and then assign javascript functionality to a control to show the label on the client side without another trip to the server.   How do you execute javascript functionality at the server within code behind? Using the example, I would like to run the Hidecontrols() function on pageload.


Answers (2)