469,572 Members | 1,281 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Reload user control?

Hi,
I'm working on a webproject where I have several different user controls
loaded on a WebForm.
A problem arises when I in one webcontrol makes a change that should be
picked up by another user control.
For example a webshop. I have a datagrid of products in the shopping
cart in one user control. In another I have an overview of the shopping
cart (lists the products and a shows an order total).
When I remove a product from my datagrid I want the overview to reflect
the changes. The only solution I could think of was to do a
Server.Transfer() in the postback to "reload" the page, but it sounds to
me like a complete waste of resources to load the page twice for a
single postback.

Does anyone have any tips on how I could do it differently?

My shopping cart overview does not have an if(!IsPostBack) clause.

Thanks in advance
/Mats
Dec 26 '05 #1
8 16700
You can dynamally load usercontrol by

UserControl userControl = this.LoadControl("virtualPath");

And put a PlaceHolder to hold the userControl

PlaceHolder.Controls.Add(userControl);

HTH

Elton Wang
"Mats Lycken" wrote:
Hi,
I'm working on a webproject where I have several different user controls
loaded on a WebForm.
A problem arises when I in one webcontrol makes a change that should be
picked up by another user control.
For example a webshop. I have a datagrid of products in the shopping
cart in one user control. In another I have an overview of the shopping
cart (lists the products and a shows an order total).
When I remove a product from my datagrid I want the overview to reflect
the changes. The only solution I could think of was to do a
Server.Transfer() in the postback to "reload" the page, but it sounds to
me like a complete waste of resources to load the page twice for a
single postback.

Does anyone have any tips on how I could do it differently?

My shopping cart overview does not have an if(!IsPostBack) clause.

Thanks in advance
/Mats

Dec 26 '05 #2
Hi,
thanks for the reply.

The thing is that the other user control already has been added when the
other one has parsed its postback...
I use LoadControl() to load the usercontrols.

Elton W wrote:
You can dynamally load usercontrol by

UserControl userControl = this.LoadControl("virtualPath");

And put a PlaceHolder to hold the userControl

PlaceHolder.Controls.Add(userControl);

HTH

Elton Wang
"Mats Lycken" wrote:

Hi,
I'm working on a webproject where I have several different user controls
loaded on a WebForm.
A problem arises when I in one webcontrol makes a change that should be
picked up by another user control.
For example a webshop. I have a datagrid of products in the shopping
cart in one user control. In another I have an overview of the shopping
cart (lists the products and a shows an order total).
When I remove a product from my datagrid I want the overview to reflect
the changes. The only solution I could think of was to do a
Server.Transfer() in the postback to "reload" the page, but it sounds to
me like a complete waste of resources to load the page twice for a
single postback.

Does anyone have any tips on how I could do it differently?

My shopping cart overview does not have an if(!IsPostBack) clause.

Thanks in advance
/Mats

Dec 26 '05 #3
The only way not to reload the entire page is to use something like AJAX or IFRAMES.

http://www.15seconds.com/issue/050526.htm

---------------------------------------------------
Trust is hard to earn, easy to lose and nearly impossible to win back
Dec 26 '05 #4
Hi Mats,

IMO, you can consider customize your ascx usercontrol to expose some public
method which can be called by external users to update its UI
view(controls....). I think the shopping cart's change will cause a
postback, yes? If so, the postback event will be the proper time you find
the userControl's reference in the Page and then call that Usercontrol's
exposed public method( which will update the usercontrol's UI/Control
properties.....)....

Also, if you've ever had a look at the WSS or ASP.NET's web part controls
and its Connections part framework, this is just something like that, when
one control's status changes (cause postback), in the postback event, the
page will find another control that should react to the changes , and call
the corresponding method.......

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Date: Mon, 26 Dec 2005 19:22:48 +0100
| From: Mats Lycken <Ma***@newsgroups.nospam>
| User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: Reload user control?
| References: <Ou**************@TK2MSFTNGP09.phx.gbl>
<2F**********************************@microsoft.co m>
| In-Reply-To: <2F**********************************@microsoft.co m>
| Content-Type: text/plain; charset=UTF-8; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <#Z**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 1-1-3-42a.vs.vs.bostream.se 82.182.18.143
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:367079
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
| thanks for the reply.
|
| The thing is that the other user control already has been added when the
| other one has parsed its postback...
| I use LoadControl() to load the usercontrols.
|
| Elton W wrote:
| > You can dynamally load usercontrol by
| >
| > UserControl userControl = this.LoadControl("virtualPath");
| >
| > And put a PlaceHolder to hold the userControl
| >
| > PlaceHolder.Controls.Add(userControl);
| >
| > HTH
| >
| > Elton Wang
| >
| >
| > "Mats Lycken" wrote:
| >
| >
| >>Hi,
| >>I'm working on a webproject where I have several different user
controls
| >>loaded on a WebForm.
| >>A problem arises when I in one webcontrol makes a change that should be
| >>picked up by another user control.
| >>For example a webshop. I have a datagrid of products in the shopping
| >>cart in one user control. In another I have an overview of the shopping
| >>cart (lists the products and a shows an order total).
| >>When I remove a product from my datagrid I want the overview to reflect
| >>the changes. The only solution I could think of was to do a
| >>Server.Transfer() in the postback to "reload" the page, but it sounds
to
| >>me like a complete waste of resources to load the page twice for a
| >>single postback.
| >>
| >>Does anyone have any tips on how I could do it differently?
| >>
| >>My shopping cart overview does not have an if(!IsPostBack) clause.
| >>
| >>Thanks in advance
| >>/Mats
| >>
|

Dec 27 '05 #5
What I mean is that each time you load usecontrol dynamically depending on
condition, even from begining.

HTH

"Mats Lycken" <Ma***@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,
thanks for the reply.

The thing is that the other user control already has been added when the
other one has parsed its postback...
I use LoadControl() to load the usercontrols.

Elton W wrote:
You can dynamally load usercontrol by UserControl userControl =
this.LoadControl("virtualPath");

And put a PlaceHolder to hold the userControl

PlaceHolder.Controls.Add(userControl);

HTH

Elton Wang
"Mats Lycken" wrote:

Hi,
I'm working on a webproject where I have several different user controls
loaded on a WebForm.
A problem arises when I in one webcontrol makes a change that should be
picked up by another user control.
For example a webshop. I have a datagrid of products in the shopping cart
in one user control. In another I have an overview of the shopping cart
(lists the products and a shows an order total).
When I remove a product from my datagrid I want the overview to reflect
the changes. The only solution I could think of was to do a
Server.Transfer() in the postback to "reload" the page, but it sounds to
me like a complete waste of resources to load the page twice for a single
postback.

Does anyone have any tips on how I could do it differently?

My shopping cart overview does not have an if(!IsPostBack) clause.

Thanks in advance
/Mats

Dec 27 '05 #6
Thanks for the tip Steven, I'll look into it!

Steven Cheng[MSFT] wrote:
Hi Mats,

IMO, you can consider customize your ascx usercontrol to expose some public
method which can be called by external users to update its UI
view(controls....). I think the shopping cart's change will cause a
postback, yes? If so, the postback event will be the proper time you find
the userControl's reference in the Page and then call that Usercontrol's
exposed public method( which will update the usercontrol's UI/Control
properties.....)....

Also, if you've ever had a look at the WSS or ASP.NET's web part controls
and its Connections part framework, this is just something like that, when
one control's status changes (cause postback), in the postback event, the
page will find another control that should react to the changes , and call
the corresponding method.......

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Date: Mon, 26 Dec 2005 19:22:48 +0100
| From: Mats Lycken <Ma***@newsgroups.nospam>
| User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: Reload user control?
| References: <Ou**************@TK2MSFTNGP09.phx.gbl>
<2F**********************************@microsoft.co m>
| In-Reply-To: <2F**********************************@microsoft.co m>
| Content-Type: text/plain; charset=UTF-8; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <#Z**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 1-1-3-42a.vs.vs.bostream.se 82.182.18.143
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:367079
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
| thanks for the reply.
|
| The thing is that the other user control already has been added when the
| other one has parsed its postback...
| I use LoadControl() to load the usercontrols.
|
| Elton W wrote:
| > You can dynamally load usercontrol by
| >
| > UserControl userControl = this.LoadControl("virtualPath");
| >
| > And put a PlaceHolder to hold the userControl
| >
| > PlaceHolder.Controls.Add(userControl);
| >
| > HTH
| >
| > Elton Wang
| >
| >
| > "Mats Lycken" wrote:
| >
| >
| >>Hi,
| >>I'm working on a webproject where I have several different user
controls
| >>loaded on a WebForm.
| >>A problem arises when I in one webcontrol makes a change that should be
| >>picked up by another user control.
| >>For example a webshop. I have a datagrid of products in the shopping
| >>cart in one user control. In another I have an overview of the shopping
| >>cart (lists the products and a shows an order total).
| >>When I remove a product from my datagrid I want the overview to reflect
| >>the changes. The only solution I could think of was to do a
| >>Server.Transfer() in the postback to "reload" the page, but it sounds
to
| >>me like a complete waste of resources to load the page twice for a
| >>single postback.
| >>
| >>Does anyone have any tips on how I could do it differently?
| >>
| >>My shopping cart overview does not have an if(!IsPostBack) clause.
| >>
| >>Thanks in advance
| >>/Mats
| >>
|

Dec 28 '05 #7
Sorry, I'm still not sure what you mean

Elton Wang wrote:
What I mean is that each time you load usecontrol dynamically depending on
condition, even from begining.

HTH

"Mats Lycken" <Ma***@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,
thanks for the reply.

The thing is that the other user control already has been added when the
other one has parsed its postback...
I use LoadControl() to load the usercontrols.

Elton W wrote:
You can dynamally load usercontrol by UserControl userControl =
this.LoadControl("virtualPath");

And put a PlaceHolder to hold the userControl

PlaceHolder.Controls.Add(userControl);

HTH

Elton Wang
"Mats Lycken" wrote:

Hi,
I'm working on a webproject where I have several different user controls
loaded on a WebForm.
A problem arises when I in one webcontrol makes a change that should be
picked up by another user control.
For example a webshop. I have a datagrid of products in the shopping cart
in one user control. In another I have an overview of the shopping cart
(lists the products and a shows an order total).
When I remove a product from my datagrid I want the overview to reflect
the changes. The only solution I could think of was to do a
Server.Transfer() in the postback to "reload" the page, but it sounds to
me like a complete waste of resources to load the page twice for a single
postback.

Does anyone have any tips on how I could do it differently?

My shopping cart overview does not have an if(!IsPostBack) clause.

Thanks in advance
/Mats


Dec 28 '05 #8
You're welcome Mats,

If there is any further problem, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Date: Wed, 28 Dec 2005 19:00:32 +0100
| From: Mats Lycken <Ma***@newsgroups.nospam>
| User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: Reload user control?
| References: <Ou**************@TK2MSFTNGP09.phx.gbl>
<2F**********************************@microsoft.co m>
<#Z**************@TK2MSFTNGP10.phx.gbl>
<Bt**************@TK2MSFTNGXA02.phx.gbl>
| In-Reply-To: <Bt**************@TK2MSFTNGXA02.phx.gbl>
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <OG**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 1-1-3-42a.vs.vs.bostream.se 82.182.18.143
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:367355
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks for the tip Steven, I'll look into it!
|
| Steven Cheng[MSFT] wrote:
| > Hi Mats,
| >
| > IMO, you can consider customize your ascx usercontrol to expose some
public
| > method which can be called by external users to update its UI
| > view(controls....). I think the shopping cart's change will cause a
| > postback, yes? If so, the postback event will be the proper time you
find
| > the userControl's reference in the Page and then call that
Usercontrol's
| > exposed public method( which will update the usercontrol's UI/Control
| > properties.....)....
| >
| > Also, if you've ever had a look at the WSS or ASP.NET's web part
controls
| > and its Connections part framework, this is just something like that,
when
| > one control's status changes (cause postback), in the postback event,
the
| > page will find another control that should react to the changes , and
call
| > the corresponding method.......
| >
| > Regards,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | Date: Mon, 26 Dec 2005 19:22:48 +0100
| > | From: Mats Lycken <Ma***@newsgroups.nospam>
| > | User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
| > | X-Accept-Language: en-us, en
| > | MIME-Version: 1.0
| > | Subject: Re: Reload user control?
| > | References: <Ou**************@TK2MSFTNGP09.phx.gbl>
| > <2F**********************************@microsoft.co m>
| > | In-Reply-To: <2F**********************************@microsoft.co m>
| > | Content-Type: text/plain; charset=UTF-8; format=flowed
| > | Content-Transfer-Encoding: 7bit
| > | Message-ID: <#Z**************@TK2MSFTNGP10.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 1-1-3-42a.vs.vs.bostream.se 82.182.18.143
| > | Lines: 1
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:367079
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Hi,
| > | thanks for the reply.
| > |
| > | The thing is that the other user control already has been added when
the
| > | other one has parsed its postback...
| > | I use LoadControl() to load the usercontrols.
| > |
| > | Elton W wrote:
| > | > You can dynamally load usercontrol by
| > | >
| > | > UserControl userControl = this.LoadControl("virtualPath");
| > | >
| > | > And put a PlaceHolder to hold the userControl
| > | >
| > | > PlaceHolder.Controls.Add(userControl);
| > | >
| > | > HTH
| > | >
| > | > Elton Wang
| > | >
| > | >
| > | > "Mats Lycken" wrote:
| > | >
| > | >
| > | >>Hi,
| > | >>I'm working on a webproject where I have several different user
| > controls
| > | >>loaded on a WebForm.
| > | >>A problem arises when I in one webcontrol makes a change that
should be
| > | >>picked up by another user control.
| > | >>For example a webshop. I have a datagrid of products in the
shopping
| > | >>cart in one user control. In another I have an overview of the
shopping
| > | >>cart (lists the products and a shows an order total).
| > | >>When I remove a product from my datagrid I want the overview to
reflect
| > | >>the changes. The only solution I could think of was to do a
| > | >>Server.Transfer() in the postback to "reload" the page, but it
sounds
| > to
| > | >>me like a complete waste of resources to load the page twice for a
| > | >>single postback.
| > | >>
| > | >>Does anyone have any tips on how I could do it differently?
| > | >>
| > | >>My shopping cart overview does not have an if(!IsPostBack) clause.
| > | >>
| > | >>Thanks in advance
| > | >>/Mats
| > | >>
| > |
| >
|

Dec 29 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by chaoy | last post: by
reply views Thread by Do | last post: by
reply views Thread by Stephen robinson | last post: by
1 post views Thread by Raed Sawalha | last post: by
2 posts views Thread by Edward Chung | last post: by
10 posts views Thread by sqlboy2000 | last post: by
3 posts views Thread by Joe | last post: by
2 posts views Thread by C | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.