G
Guest
Hey all, I realize this must be a fairly common requirement in ASP.NET but I
have yet to come across the right way to do it.
Basically, right now I have a single asp:label on my webpage and I am
writing out to the Text property of that Label object.
However, now I would like to write a control like a button to that Text and
associate an event handler with that button.
How should I do that - or am I going about this in the wrong way - i.e.
should I be creating my own custom web control?
Anyway, here is my attempt at writing an asp:button out to the page and
associating an event handler with it:
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
Button button = new Button ();
button.Click += new EventHandler(nextButtonClick);
htw.Write(button.);
htw.Flush();
MyLabel.Text += sb.ToString();
Thanks for any help,
Novice
have yet to come across the right way to do it.
Basically, right now I have a single asp:label on my webpage and I am
writing out to the Text property of that Label object.
However, now I would like to write a control like a button to that Text and
associate an event handler with that button.
How should I do that - or am I going about this in the wrong way - i.e.
should I be creating my own custom web control?
Anyway, here is my attempt at writing an asp:button out to the page and
associating an event handler with it:
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
Button button = new Button ();
button.Click += new EventHandler(nextButtonClick);
htw.Write(button.);
htw.Flush();
MyLabel.Text += sb.ToString();
Thanks for any help,
Novice