Advertisements

"Amelyan" <> wrote in
news::
> How can I get state of dynamically created controls (RadioButton,
> CheckBox, TextBox.Text) on post back when I click submit button?
>
> The only way I know is by traversing Response.Form enumberator;
> Response.Form.GetEnumerator(), etc. while, identifying specific
> controls by programmatically assigned unique id (e.g.
> MyButton_AnswerID_123).
>
> However, I am not sure if that is the proper way. What is the common
> practice?

On postback, recreate the cotrols - then you can access the previous
viewstate of the controls.

Advertisements

Guest

Lucas Tam wrote:
> "Amelyan" <> wrote in
> news::
>
> > How can I get state of dynamically created controls (RadioButton,
> > CheckBox, TextBox.Text) on post back when I click submit button?
> >
> > The only way I know is by traversing Response.Form enumberator;
> > Response.Form.GetEnumerator(), etc. while, identifying specific
> > controls by programmatically assigned unique id (e.g.
> > MyButton_AnswerID_123).
> >
> > However, I am not sure if that is the proper way. What is the
common
> > practice?
>
> On postback, recreate the cotrols - then you can access the previous
> viewstate of the controls.
>
> --
> Lucas Tam ()
> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/

What I do is traverse the source of the controls...

I generate the controls with an XSLT stylesheet that produces the
output from XML read dynamically from a database. I read the template
again from the database on post back, and traverse the results there.
I isolate particular controls using the Page.FindControl method.

That way, if I'm only looking for some of them, I don't have to read
through the whole response.

Do you have a simple examle of generating the controls with an XSLT
stylesheet that produces the output from XML read dynamically from a
database, then reading the template again from the database on post back,
and traversing the results there, and isolating particular controls using
the Page.FindControl method?

Thanks,
-Amelyan

<> wrote in message
news:...
>
> Lucas Tam wrote:
>> "Amelyan" <> wrote in
>> news::
>>
>> > How can I get state of dynamically created controls (RadioButton,
>> > CheckBox, TextBox.Text) on post back when I click submit button?
>> >
>> > The only way I know is by traversing Response.Form enumberator;
>> > Response.Form.GetEnumerator(), etc. while, identifying specific
>> > controls by programmatically assigned unique id (e.g.
>> > MyButton_AnswerID_123).
>> >
>> > However, I am not sure if that is the proper way. What is the
> common
>> > practice?
>>
>> On postback, recreate the cotrols - then you can access the previous
>> viewstate of the controls.
>>
>> --
>> Lucas Tam ()
>> Please delete "REMOVE" from the e-mail address when replying.
>> http://members.ebay.com/aboutme/coolspot18/
>
> What I do is traverse the source of the controls...
>
> I generate the controls with an XSLT stylesheet that produces the
> output from XML read dynamically from a database. I read the template
> again from the database on post back, and traverse the results there.
> I isolate particular controls using the Page.FindControl method.
>
> That way, if I'm only looking for some of them, I don't have to read
> through the whole response.
>

Guest

yes I do, as a matter of fact. Although explaining it is a bit heavy,
so I'll give it my best shot:

The CreateForm() reads the template which is returned as a FOR XML
AUTO query from the SQL server. It transforms it into ASP.NET code by
applying the stylesheet, then ParseControl will actually render it on
the page from a text stream. Then, ProcessResults reads the template
again, and walks down through it. In this example, it's building an
XML document from the results, but you needn't do that if you don't
want to. I just wrote this XML in, XML out so that I can change the
backend at some point in the future if I decide to dump SQL server.
Then all I'd have to do is change the DB calls to file reads or
whatever.

Notice that you can't use ParseControl to insert custom user controls
(peoplepicker and duedatepicker), you have to have a placeholder in
there, and substitute your controls in as childcontrols after the fact.

I've cut a bit of the end off my ProcessResults but you get the idea of
what you're asking from this here.

I have for you the template from the database, the xslt stylesheet, and
the code I used

Some of this create survey was from a completely different form I had,
so the comments and switch statements might not apply to this template.
It just goes to show you how little you have to do to the code to
completely change the form.

if (ctrl is PlaceHolder)
{
//we're taking it on faith that only DueDatePickers will be in
placeholders,
//but that's ok becuase if that isn't the case, we would have
to specify that
//manually, and we'd know about the change.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!