Ask a Question related to ASP.NET Building Controls, Design and Development.
-
nickname #1
- Dynamic controls question
I have a Table in my page. I must load some webcontrols dynamically
into this table, after the click of a button. These dynamic controls
can fire events. They also must keep their viewstate (so I must add
them in the Init phase).
Ok... after the button is clicked I am able to load the dynamic
controls into the table without any problem. Since the page that hosts
everything can postback, I must rebuild these dynamically created
controls on each roundtrip, otherwise they won't be available after the
postback.
I am doing something like this:
1) button is pressed...
2) In the button click event handler I add the dynamic controls into
the table. Then I save into Session some custom-information needed to
rebuild the dynamic controls (such as the number of controls, their
ID's and their type).
Then the page is rendered with the dynamic controls visible to the
user.
When the user does something that causes a postback, in the Init event
handler I restore the controls custom-information from Session and
rebuild them into the table again.
My question is: is there a better way to do this? It seems a bit
"hacky" to me... but I can't think of other way.
One more thing: is it possible to avoid the use of Session? It thought
of using ViewState, but it is not available on the Init phase. And I
can't add the dynamic controls in the Load phase, because I need to
keep viewstate for these dynamic controls (and the Load phase happens
after the LoadViewState method is called).
I appreciate any help and advice.
nickname Guest
-
Dynamic Controls
hi, Here's what I'm trying to do. A simple datagrid that is populated by a variable amount of data, which displays a different amount of rows. ... -
dynamic controls in asp.net....Please Help...
Hello People, I would appreciate your responses on this. I am writing an asp.net web-application involving C#. I am actually building a test... -
Newbie - Dynamic Controls
I am building a webpage that pulls what would have been an include file in ASP 3. Basically it is an HTML navigation bar. Instead of using an inc... -
Dynamic Controls - Still!
Hi Jim Thanks for your help. I changed the table from an ASP.Net table to an HTML table. I am till having the problem of the control placed... -
Dynamic Controls using ParseControl
Hello everybody, I am using xml and xslt to generate dynamic asp server controls on the page. What I do is I store the control type and their... -
Teemu Keiski #2
Re: - Dynamic controls question
Hi,
it depends on your case so much, but basically if it is question just adding
controls to a list ands keeping it etc, then maybe
some type of solution with existing databound contrtols like Repeater would
work. See my blog post:
[url]http://aspadvice.com/blogs/joteke/archive/2006/01/06/14568.aspx[/url]
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
[url]http://blogs.aspadvice.com/joteke[/url]
"nickname" <leodippolito@gmail.com> wrote in message
news:1157992583.672031.296730@m73g2000cwd.googlegr oups.com...>I have a Table in my page. I must load some webcontrols dynamically
> into this table, after the click of a button. These dynamic controls
> can fire events. They also must keep their viewstate (so I must add
> them in the Init phase).
>
> Ok... after the button is clicked I am able to load the dynamic
> controls into the table without any problem. Since the page that hosts
> everything can postback, I must rebuild these dynamically created
> controls on each roundtrip, otherwise they won't be available after the
> postback.
>
> I am doing something like this:
>
> 1) button is pressed...
> 2) In the button click event handler I add the dynamic controls into
> the table. Then I save into Session some custom-information needed to
> rebuild the dynamic controls (such as the number of controls, their
> ID's and their type).
>
> Then the page is rendered with the dynamic controls visible to the
> user.
>
> When the user does something that causes a postback, in the Init event
> handler I restore the controls custom-information from Session and
> rebuild them into the table again.
>
> My question is: is there a better way to do this? It seems a bit
> "hacky" to me... but I can't think of other way.
>
> One more thing: is it possible to avoid the use of Session? It thought
> of using ViewState, but it is not available on the Init phase. And I
> can't add the dynamic controls in the Load phase, because I need to
> keep viewstate for these dynamic controls (and the Load phase happens
> after the LoadViewState method is called).
>
> I appreciate any help and advice.
>
Teemu Keiski Guest



Reply With Quote

