implementing runat in HtmlTextWriterAttribute
Posted
by
user525116
on Stack Overflow
See other posts from Stack Overflow
or by user525116
Published on 2011-01-04T08:44:33Z
Indexed on
2011/01/04
8:54 UTC
Read the original article
Hit count: 147
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>
© Stack Overflow or respective owner