Rectangle 27 0

c ASP.NET Scope of user control for javascript functions?


function CLIENTID_javascriptFunction{
}
function javascriptFunction(id){

}

That way you don't need to have multiple copies of the same javascript function.

You'd have on function at the global level :

and call it with the id of the dom object you're interested in. (use ClientID to get the DOM id of the control)

usually you can have one function and have it perform it's work on the whole page or you can change it to take a parameter ( a reference to the usercontrol you're interested in )

yes u r right but sometimes I had to go the (CLIENTID_javascriptFunction) instead of passing a large number of parameters to a global declared function

Note
Rectangle 27 0

c ASP.NET Scope of user control for javascript functions?


If you did want to use a user control, this seem like a good way to protect the scope -> programmerramblings.blogspot.com/2011/07/

Turns out that in this case it would be better to use a server control instead of a user control. Server controls seem to be a little more complicated to make but they do protect the scope of the javascript functions.

Note
Rectangle 27 0

c ASP.NET Scope of user control for javascript functions?


function CLIENTID_javascriptFunction{
}
function javascriptFunction(id){

}

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

That way you don't need to have multiple copies of the same javascript function.

You'd have on function at the global level :

and call it with the id of the dom object you're interested in. (use ClientID to get the DOM id of the control)

usually you can have one function and have it perform it's work on the whole page or you can change it to take a parameter ( a reference to the usercontrol you're interested in )

yes u r right but sometimes I had to go the (CLIENTID_javascriptFunction) instead of passing a large number of parameters to a global declared function

Note
Rectangle 27 0

c ASP.NET Scope of user control for javascript functions?


function <%= ClientID %>javaFunction()
{
  //code here
}

This is basically what I have been doing. I'm hoping that the guys at Microsoft made a way to allow you to reference the user controls individuality, rather than calling it like this.

you will have a function declaration for each user control with the client ID of the control plus function name

Note