开发者

infragistics get clientID of dropdown in Rowedit template

i have a infragistics web grid which has row edit template. Row edit template contains drop down list. Now wh开发者_如何学编程en i change the selected index of drop down.. i need to get the client id of the drop down.. the web grid is in Content place holder..

i am using the below code..

ctl00_ContentPlaceHolder1_webModGrid_ctl00_ddlScope

but it is giving error..

Microsoft JScript runtime error: Object required


you can try to use the switch 'ClientIDMode' and its value Static

http://msdn.microsoft.com/en-us/library/system.web.ui.clientidmode.aspx


It is possible to evaluate the ClientID property of the required control (and its client-side tag object) in the following manner:

var clientID = '<%=ddlScope.ClientID%>';
var element = document.getElementById(clientID);
if (element) {
}

Otherwise, if the DropDownList is placed into the INamingContainer, it is possible to render the corresponding client-side object from the page’s code behind by handling the control’s Init event and using the ClientScript.RegisterStartupScript method in the following manner:

<asp:DropDownList ID="ddlScope" runat="server" OnInit="ddlScope_Init">
</asp:DropDownList>

protected void ddlScope_Init(object sender, EventArgs e) {
    DropDownList ddl = (DropDownList)sender;
    string script = string.Format("var _{0} = document.getElementById('{1}');", ddl.ID, ddl.ClientID);
    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ANY_KEY", script, true);
}

var element = _ddlScope;
alert(element);

Does it make a sense?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜