Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   conditional loading of ascx controls. (http://www.velocityreviews.com/forums/t773483-conditional-loading-of-ascx-controls.html)

sameerpande 06-09-2004 06:16 AM

conditional loading of ascx controls.
 
Hello friends
I have 5 ascx controls on a aspx page, and i have to show one control at a time. These all controls are dyanamic and user can traverse from one control to other by some conditions ,but right now my controls gets loaded whenever i come to this page,i want to restict that and want to load each control when it is required
right now i have implemented the logic for conditional rendering of these controls but in this case all controls gets loaded and initilize the all the required conditions.

Jacques 06-09-2004 07:53 AM

Re: conditional loading of ascx controls.
 
If I understand you correctly you want to be able to add the user control
only when certain conditions are met!?

If that is the case then there is the option to add a placeholder control to
the page in the position where you intend the contents of the control to
appear.

Remove the 5 current controls from the page.

Wherever it is that you are validating the user input, which should allow
the next control to become available you could use code such as this to add
the relevant User Control

placeHolder1.Controls.Add(Page.LoadControl("../UserControls/myControl.ascx")
;

Hope that helped.

"sameerpande" <sameerpande@india.com> wrote in message
news:F62FDDE0-13CE-485C-A73D-69755D61D035@microsoft.com...
> Hello friends ,
> I have 5 ascx controls on a aspx page, and i have to show one control at

a time. These all controls are dyanamic and user can traverse from one
control to other by some conditions ,but right now my controls gets loaded
whenever i come to this page,i want to restict that and want to load each
control when it is required.
> right now i have implemented the logic for conditional rendering of these

controls but in this case all controls gets loaded and initilize the all the
required conditions.



Robert Koritnik 06-09-2004 11:06 AM

Re: conditional loading of ascx controls.
 
U should use LoadControl method for this, but if you have postbacks, you
should be aware of the viewstate problems. You can load the appropriate ASCX
in the Init phase of the page, but you should ignore ProcessPostBack
exceptions due to different fields used on different controls. That way your
controls won't load until you explicitely call LoadControl. One other good
thing is that your viewstate won't have all items os all controls but only
those that will dynamicly be loaded. PartialCachingControl will have it's
instance when put in some container, not before. if you'll have problems
with setting properties before the control is put inside container.

--
RobertK
{ Clever? No just smart. }


"sameerpande" <sameerpande@india.com> wrote in message
news:F62FDDE0-13CE-485C-A73D-69755D61D035@microsoft.com...
> Hello friends ,
> I have 5 ascx controls on a aspx page, and i have to show one control at

a time. These all controls are dyanamic and user can traverse from one
control to other by some conditions ,but right now my controls gets loaded
whenever i come to this page,i want to restict that and want to load each
control when it is required.
> right now i have implemented the logic for conditional rendering of these

controls but in this case all controls gets loaded and initilize the all the
required conditions.




All times are GMT. The time now is 07:56 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.