Ask a Question related to ASP.NET General, Design and Development.
-
John #1
Loading User controls
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 page, setting the usercontrol's visible to false still fires the
Page_Load event. Isn't this unnecessary overhead when it doesn't even show
in my page.
2. For my usercontrols to be able to see one another's methods, do I have to
define the usercontrol within the code-behind of each usercontrol I wish to
reference?
3. To dynamically load/unload usercontrols, must I register them at least
within my page at design-time? This seems 'un-dynamic' to me.
4. What method do I use to run code the first time my user control is
dynamically loaded. I don't want to run the code again after that unless it
is removed then re-loaded again.
There clearly is much for me to learn about usercontrols. If the above four
questions could please be answered and perhaps a pointer to some good online
reading material, I really would appreciate this!
Thanks.
Regards
John.
John Guest
-
using javascript in User controls to access server controls of the user control
Hello all, I have an asp.net textbox (named txtHidden) and an HtmlButton(named btnAction). I wanted to write a javascript function which will get... -
Loading user controls many times in a page is a good solution?
Hi, One of the features in my project is to show the content one by one. We have several types of content, such as "Articles", "Books", "Images"... -
Loading Different User Controls into a Single DataGrid
I have a situation where I am going to create 5 similar, but different user controls that all need to be bound into one datagrid. Basically,... -
Loading/Unloading web user controls dynamically in code - Does this look right?
You ought to check out the DynamicPlaceHolder control instead of using the builtin Placeholder. ... -
Loading a user controls in Design View
Not sure I understand you fully, but it sounds like you want to build a custom Designer for your control. If so, see: ... -
Marina #2
Re: Loading User controls
1. Loading a control and making it not visible are 2 different things.
Invisible controls will not be rendered to the page - but they are still
created, and their page_load will still fire.
2. You should define public methods to allow this. You will also need to
have a way for one control to get a reference to the instance of the other
control.
3. To dynamically load controls, you do not need to register anything with
the page. You can just call the LoadControl method of the page, and then add
the newly created usercontrol to your page.
"John" <a@b.com> wrote in message
news:euKyBt$PDHA.1608@TK2MSFTNGP11.phx.gbl...on> 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 cellsto> my page, setting the usercontrol's visible to false still fires the
> Page_Load event. Isn't this unnecessary overhead when it doesn't even show
> in my page.
>
> 2. For my usercontrols to be able to see one another's methods, do I haveto> define the usercontrol within the code-behind of each usercontrol I wishit> reference?
>
> 3. To dynamically load/unload usercontrols, must I register them at least
> within my page at design-time? This seems 'un-dynamic' to me.
>
> 4. What method do I use to run code the first time my user control is
> dynamically loaded. I don't want to run the code again after that unlessfour> is removed then re-loaded again.
>
>
> There clearly is much for me to learn about usercontrols. If the aboveonline> questions could please be answered and perhaps a pointer to some good> reading material, I really would appreciate this!
>
> Thanks.
>
> Regards
> John.
>
>
Marina Guest
-
Sreejumon[MVP] #3
Loading User controls
Hi John,
Here is the answer to your queries.
1. If you are using the register directive to load the
userconoreol (I mean design time loading), Then page load
of the suer control will run even if the vicible property
= false. This is to initialize the control.
2&3. If you want to dynamically load the user control from
code behind please use the loadcontrol( ) method with
refernce to *.ascx file. No need to use both register &
loadcontrol simultaniously.
4. If you enbael the page caching for your usercontrol (I
mean fragment caching) then it wont take much time to load
the usercontrol next time.
The following links will be usefull.
[url]http://samples.gotdotnet.com/quickstart/aspplus/doc/webpage[/url]
lets.aspx
[url]http://www.codeproject.com/aspnet/aspnetusercontrol2.asp[/url]
[url]http://www.dotnetjohn.com/articles/articleid52.aspx[/url]
regards
Sreejumon[MVP]
DOTNET makes IT happen
dynamically>-----Original Message-----
>Hi all,
>
>I'm having a little problem understanding the concepts offew tables cells on>loading/unloading user conrols:
>
>1. If I have a couple of usercontrols embedded within afires the>my page, setting the usercontrol's visible to false stilldoesn't even show>Page_Load event. Isn't this unnecessary overhead when itmethods, do I have to>in my page.
>
>2. For my usercontrols to be able to see one another'susercontrol I wish to>define the usercontrol within the code-behind of eachregister them at least>reference?
>
>3. To dynamically load/unload usercontrols, must Ime.>within my page at design-time? This seems 'un-dynamic' touser control is>
>4. What method do I use to run code the first time myafter that unless it>dynamically loaded. I don't want to run the code againIf the above four>is removed then re-loaded again.
>
>
>There clearly is much for me to learn about usercontrols.to some good online>questions could please be answered and perhaps a pointer>reading material, I really would appreciate this!
>
>Thanks.
>
>Regards
>John.
>
>
>.
>Sreejumon[MVP] Guest
-
Kurt #4
Re: Loading User controls
John
Have you gotten worked out your solution to loading your controls
dynamically, it sounds like you are having close to the same problrems I am
having.
Kurt
"John" <a@b.com> wrote in message
news:euKyBt$PDHA.1608@TK2MSFTNGP11.phx.gbl...on> 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 cellsto> my page, setting the usercontrol's visible to false still fires the
> Page_Load event. Isn't this unnecessary overhead when it doesn't even show
> in my page.
>
> 2. For my usercontrols to be able to see one another's methods, do I haveto> define the usercontrol within the code-behind of each usercontrol I wishit> reference?
>
> 3. To dynamically load/unload usercontrols, must I register them at least
> within my page at design-time? This seems 'un-dynamic' to me.
>
> 4. What method do I use to run code the first time my user control is
> dynamically loaded. I don't want to run the code again after that unlessfour> is removed then re-loaded again.
>
>
> There clearly is much for me to learn about usercontrols. If the aboveonline> questions could please be answered and perhaps a pointer to some good> reading material, I really would appreciate this!
>
> Thanks.
>
> Regards
> John.
>
>
Kurt Guest
-
John #5
Re: Loading User controls
Hi Kurt,
I have finally got it working, although now I'm treading water in another
area (also user control related). If there is anything in particular I could
help with, let me know.
Regards
John.
[email]finnej00REMOVETHIS@hotmail.com[/email]
"Kurt" <k_nojunk@larimore.net> wrote in message
news:edDUdfMQDHA.704@tk2msftngp13.phx.gbl...am> John
>
> Have you gotten worked out your solution to loading your controls
> dynamically, it sounds like you are having close to the same problrems Ishow> having.
>
> Kurt
>
> "John" <a@b.com> wrote in message
> news:euKyBt$PDHA.1608@TK2MSFTNGP11.phx.gbl...> on> > 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> > my page, setting the usercontrol's visible to false still fires the
> > Page_Load event. Isn't this unnecessary overhead when it doesn't evenhave> > in my page.
> >
> > 2. For my usercontrols to be able to see one another's methods, do Ileast> to> to> > define the usercontrol within the code-behind of each usercontrol I wish> > reference?
> >
> > 3. To dynamically load/unload usercontrols, must I register them at> it> > within my page at design-time? This seems 'un-dynamic' to me.
> >
> > 4. What method do I use to run code the first time my user control is
> > dynamically loaded. I don't want to run the code again after that unless> four> > is removed then re-loaded again.
> >
> >
> > There clearly is much for me to learn about usercontrols. If the above> online> > questions could please be answered and perhaps a pointer to some good>> > reading material, I really would appreciate this!
> >
> > Thanks.
> >
> > Regards
> > John.
> >
> >
>
John Guest



Reply With Quote

