If I pass a ClientID to a javascript function as a parameter without including the single quotes around it, it gets passed as a reference to the control itself which can then be used without first calling getElementByID.
I can’t find this behaviour documented anywhere, is this a browser specific thing or a .net thing or what?
I am setting up the call like this in code-behind…
protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add('onClick', string.Format('showvalue({0})', TextBox1.ClientID)); }
My concern is that this may not work in older versions of IE. Thanks.
Add quotes around your ID value when you generate the JS code e.g: string.Format(‘showvalue(‘{0}‘)’, TextBox1.ClientID)
Without quotes, showValue gets an instance of the global variable with your ClientID name that usually is the DOM element your control rendered.