我需要将div客户端ID传递给转发器的JavaScript
我在转发器内有3个div我有onmouSEOver事件我想抓住div元素的客户端id有没有办法我可以通过div元素的确切客户端
你们能帮助我吗谢谢
解决方法
这样的事情(如果我理解正确的话):
标记:
<asp:Repeater id="myRepeater" OnItemDataBound="myRepeater_ItemDataBound" runat="server"> <ItemTemplate> <div id="myDiv" runat="server">......</div> </ItemTemplate> </asp:Repeater>@H_502_13@代码隐藏:
protected void myRepeater_ItemDataBound(object sender,RepeaterItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { HtmlGenericControl myDiv = e.Item.FindControl("myDiv") as HtmlGenericControl; // you can just pass "this" instead of "myDiv.ClientID" and get the ID from the DOM element myDiv.Attributes.Add("onmouSEOver","doStuff('" + myDiv.ClientID + "');"); } }@H_502_13@