infragistics get clientID of dropdown in Rowedit template

有些话、适合烂在心里 提交于 2020-01-06 05:08:31

问题


i have a infragistics web grid which has row edit template. Row edit template contains drop down list. Now when 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


回答1:


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

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




回答2:


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?



来源:https://stackoverflow.com/questions/5364426/infragistics-get-clientid-of-dropdown-in-rowedit-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!