Reputation: 39
I am using this div inside a repeater.
<div class="view" id="View">
I want this div control in asp.net c# code. This is my code now:
HtmlGenericControl h3name = null;
h3name = (HtmlGenericControl)RepeaterView2.Items[count].FindControl("View");
h3name.Style.Add("width", CHeight.ToString());
But I did not get the control. How can I solve this problem?
Upvotes: 3
Views: 20767
Reputation: 6568
HtmlGenericControl
defines the methods, properties, and events for all HTML server control elements not represented by a specific .NET Framework class.
So if its a server control you can simply use:
HtmlGenericControl sample= e.Item.FindControl("YOURDIVNAME") as HtmlGenericControl;
and also add runet="server"
to your div
.
Upvotes: 12
Reputation: 309
First add a runat server in your div
<div class="view" id="View" runat="server">
now in item bound event of your repeater find it like
HtmlGenericControl sample= e.Item.FindControl("View") as HtmlGenericControl
Upvotes: 2