473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Loading controls dynamically in ASP.Net

Hello,

I am developing a page that has several custom web user controls that
need to be loaded dynamically. Some of the controls are loaded based
on the action (button-click) of a different control in the parent page.
Currently what I have to do to make this work is set a session
variable to load/unload a particular control and do a Server.Transfer
to the page itself from the Button_Click event. Is this a good way of
loading controls dynamically or is there a better way to do this? I am
using ASP.Net 1.1. Thanks.

Regards

Mar 22 '06 #1
3 1178
didn't understand why are you using a Session variable!?

Mar 22 '06 #2
didn't understand why are you using a Session variable!?

Mar 22 '06 #3
Let's say that I have a page called Test.aspx which contains a button
called Button1 that has a corresponding Button1_Click event handler.
Let's also say that I have a control called TestControl.ascx which
contains another button called Button2. TestControl is added
dynamically due to Button1 click. When Button1 is clicked the page
execution happens as follows:

- Page_Load
- Button1_Click

If I have code inside Button1_Click to dynamically add the TestControl,
the next time the page is reloaded due to some other actions, say as a
result of Button2_Click in TestControl, the TestControl itself is not
loaded anymore. So I needed to have the logic in the Page_Load event
to check for a session variable to check if the TestControl should be
loaded or not. That way the TestControl is loaded as long as the
session variable is "true". On Button1_Click I set session variable to
"true" and do a Server.Transfer to itself. The Page_Load event looks
for that session variable and if it is set to true it loads the user
control dynamically.

Is there a better way of doing this? Thank you very much.

Mar 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John | last post by:
Hi all, I'm having a little problem understanding the concepts of dynamically loading/unloading user conrols: 1. If I have a couple of usercontrols embedded within a few tables cells on my...
1
by: kanones | last post by:
Hi - I am seeing some performance degradation when I am loading a control dynamically onto a page with multiple other dynamical controls using Page.LoadControl versus dragging and dropping it...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
2
by: Dave A | last post by:
I just don't get this... If I need to dynamically load controls into a web page I simply need to go PlaceHolder1.Controls.Add(new Button()); or similar. However when I need to dynamically...
1
by: Bob Rock | last post by:
Hello, I'm new to ASP.NET and I've been looking into the topic of dynamically loading (typically accomplished with a LoadControl followed by a MyControl.Controls.Add()) both user controls and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.