asp.net - C# custom control to render other controls -



asp.net - C# custom control to render other controls -

how can utilize custom command render other controls? obviously, @ render stage, late. test works not contain <asp:sometag>, test2 want able write out , render properly

protected override void render(htmltextwriter writer) { const string test = @"<a href='http://www.something.com'></a>"; const string test2 = "<asp:hyperlink id='hyperlink1' runat='server' navigateurl='www.something.com'>some text</asp:hyperlink>"; writer.write(test2); }

you can override createchildcontrols method as shown in example:

protected override void createchildcontrols() { // add together literalcontrol current controlcollection. this.controls.add(new literalcontrol("<h3>value: ")); // create text box control, set default text property, // , add together controlcollection. textbox box = new textbox(); box.text = "0"; this.controls.add(box); this.controls.add(new literalcontrol("</h3>")); }

instead of literal/textbox controls, instantiate , add together hyperlink control, e.g:

var link = new hyperlink(); link.navigateurl = "..."; link.text = "..."; this.controls.add(link);

c# asp.net custom-controls rendering

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -