Hi,
I would like to run some Javascript directly *after* the RadControls are created on the client-side. If I use "ScriptManager.RegisterStartupScript" then the javascript is inserted *before* the RadControls are created.
What I am ultimately trying to do is get a "handle" to all of my client-side RadControls. I know that I can call $find to get them, but I prefer to assign them all to variables on page load then access those variables. Here is an example:
The javascript should be generated on the server like this:
Now, on the client, I could just access "BAN.get_value()". The problem, of course, is that "$find" fails to find the control because this script executes before the client-side control is created. To work-around the problem I am currently doing a two step process (declare the variables then assign them during page load) like this:
If I could just get my javascript to run *after* the RadControls are created I could clean this up a bit.
Thanks!
Scott
P.S. It would be nice to be able set a property on the control (e.g. RadControl.ClientSideId) and have the control do this for us automatically!
I would like to run some Javascript directly *after* the RadControls are created on the client-side. If I use "ScriptManager.RegisterStartupScript" then the javascript is inserted *before* the RadControls are created.
What I am ultimately trying to do is get a "handle" to all of my client-side RadControls. I know that I can call $find to get them, but I prefer to assign them all to variables on page load then access those variables. Here is an example:
The javascript should be generated on the server like this:
js =
"var BAN = $find('" + BAN.ClientID + "'); ";
ScriptManager.RegisterStartupScript(this, this.GetType(), "InitControls", js, true);
Now, on the client, I could just access "BAN.get_value()". The problem, of course, is that "$find" fails to find the control because this script executes before the client-side control is created. To work-around the problem I am currently doing a two step process (declare the variables then assign them during page load) like this:
| string js = "var BAN, CompanyName, Contact, Address1, Address2, City, State, Zip, LocalBAN, Phone, Email; "; |
| ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "DeclareControls", js, true); |
| js = "BAN = $find('" + BAN.ClientID + "'); "; |
| js += "CompanyName = $find('" + CompanyName.ClientID + "'); "; |
| js += "Contact = $find('" + Contact.ClientID + "'); "; |
| js += "Address1 = $find('" + Address1.ClientID + "'); "; |
| js += "Address2 = $find('" + Address2.ClientID + "'); "; |
| js += "City = $find('" + City.ClientID + "'); "; |
| js += "State = $find('" + State.ClientID + "'); "; |
| js += "Zip = $find('" + Zip.ClientID + "'); "; |
| js += "LocalBAN = $find('" + LocalBAN.ClientID + "'); "; |
| js += "Phone = $find('" + Phone.ClientID + "'); "; |
| js += "Email = $find('" + Email.ClientID + "'); "; |
| ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "InitControls", "function InitControls() {" + js + "}", true); |
| ScriptManager.RegisterStartupScript(this, this.GetType(), "InitControlsCall", "Sys.Application.remove_load(InitControls); Sys.Application.add_load(InitControls);", true); |
If I could just get my javascript to run *after* the RadControls are created I could clean this up a bit.
Thanks!
Scott
P.S. It would be nice to be able set a property on the control (e.g. RadControl.ClientSideId) and have the control do this for us automatically!