implementing runat in HtmlTextWriterAttribute
- by user525116
Hi dear friends, I have a custom asp.net control.
public class Window : WebControl {
protected override void RenderContents(HtmlTextWriter wr) {
wr.AddAttribute("runat", "server",true);
wr.AddAttribute("id", this.UniqueID, false);
wr.RenderBeginTag(HtmlTextWriterTag.Div);
wr.RenderEndTag();
wr.WriteLine();
base.RenderContents(wr);
}
}
And this is my result after compile and use the control:
<cc1:Window ID="Window1" runat="server" />
Use standard definition DIV with standard format:
<div runat="server" id="aaaa"></div>
After compile my web page to use this web custom control, this is render browser source of my web page:
<span id="Window1"><div runat="server" id="Window1"></div></span>
<div id="aaaa"></div>