Passing control's ID to javascript via ScriptControlDescriptor
Posted
by markiz
on Stack Overflow
See other posts from Stack Overflow
or by markiz
Published on 2009-11-24T09:14:07Z
Indexed on
2010/04/07
8:03 UTC
Read the original article
Hit count: 202
I create a control in CreateChildControls():
HtmlGenericControl mycontrol= HtmlGenericControl("li");
mycontrol.ID = "controlID";
controlId = mycontrol.ID;
protected virtual IEnumerable<ScriptDescriptor> GetScriptDescriptors()
{
ScriptControlDescriptor descriptor = new ScriptControlDescriptor("Project.TEditor", this.ClientID);
descriptor.AddProperty("controlId", controlId);
return new ScriptDescriptor[] { descriptor };
}
Then in javascript i try to find this control using the ID property:
alert($get(this.get_controlId()));
I get null because the actual control ID has a prefix that was added by asp.
How to solve that?
© Stack Overflow or respective owner