Is there any way that I can create a div runat server? So can I turn it into a control? In asp.net?
EDIT: How can I tell my code below to create the div id = test runarat server? yes This will make server-side controls and you can generate it in code using Edit per comment: or
while (reader.Read ()) {System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl ("div"); Div.Attributes ["class"] = "test"; //div.Style["float "] =" left "; Div.ID = "test"; Image IMG = new image (); Img.ImageUrl = String.Format ("{0}", reader.getstring (1)); // this line to SQL syntax // img Need to represent in iJurl = "~ / UserData / 2 / UploadMag / Batman-for-Facebook.JPG"; Img.AlternateText = "Test Image"; Div.Controls.Add (img); Div.Controls.Add (ParseControl (String.Format ("& amp; nbsp;" + "{0}", Reader. GetString (0))); Div.Style ["Clear"] = "Both"; Test1.Controls.Add (div); }
& lt; Div runat = "server" & gt; & Lt; / Div & gt;
var myDiv = new HtmlGenericControl ("div"); Edit: The one you are generating is Server Side Control, there is no need to add
runat = "server" .
& lt; Div onclick = "warning ('hello')" runat = "server" & gt; & Lt; / Div & gt;
var myDiv = new HtmlGenericControl ("div"); MyDiv.Attributes.Add ("OnClick", "Alert ('Hello'););
Comments
Post a Comment