I have a div with id="myDiv" and runat="server" inside a listview with id="lvItem".I need to access the div in code behind to add width of the div at runtime.How can I access the div from codebehid using C#?Can anyone help me?
A:
Just add an Asp:Panel instead. Asp:Panel in ASP.NET = DIV on the front end.
So basically this would be your code
ASP.NET
<asp:Panel id="myDiv" runat="server">
</asp:Panel>
Code Behind
Panel myDiv = (Panel)myListView.FindControl("myDiv");
myDiv.Attributes.Add("style", "width: 100px");
Marko
2010-07-30 05:11:09
this does not work
andrew Sullivan
2010-07-30 10:57:17
A:
<div id="coolmenu" runat="server">
</div>
HtmlControl htmlDivControl = (HtmlControl)Page.FindControl("coolmenu");
(htmlDivControl.Style["width"]) ="30px";
anishmarokey
2010-07-30 05:14:49