ParseControl With Multiple Controls in One Input String

P

PB

According to the documentation, ParseControl returns a parsed control from
an input string. The documentation seems to assume that *one* control will
be parsed from the string.

My implementation will require an unknown number of controls (always at
least one) to be parsed from the string... after which I inject the
resulting HTML into a PlaceHolder control (see code below).

In my testing, it appears that ParseControl will successfully parse
*multiple* controls from the string (not just one).

My question: Can I safely assume that ParseControl will work fine with
multiple controls in the input string? By "work fine" I mean that (1) it
doesn't matter how many controls are possibly in the input string, and (2)
when I go to rebuild the page during PostBack operations, ParseControl will
parse the controls in the same order every time (assuming the exact same
input string that was originally supplied prior to any PostBack)? I will
need for these controls to maintain VeiwState, so I need to be sure that my
implementation will be reliable.

The following is a sample/model of what I'm doing: The input string contains
an HTML table that has two buttons.

string s = "<table border=2><tr><td>Yo - this is my
table</td></tr><tr><td><asp:button text='Click here!' runat='server'
/></td></tr><tr><td><asp:button text='No, Click here!' runat='server'
/></td></tr></table>";
System.Web.UI.Control c = ParseControl(s);
ContentPlaceHolder.Controls.Add(c);

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top