updateproblem with usercontrol, page and masterpage

A

Alexander Widera

Hi,

the situation is the following:

There is this masterpage:
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="mymaster.master.cs" Inherits="mymaster" %>

<%@ Register tagprefix="myc" tagname="BasketSmall"
Src="shop/basket_small.ascx" %>

<html>

<body>

<form id="form1" runat="server">

<myc:BasketSmall runat="server" ID="smallbasket" />

<asp:contentplaceholder runat="server" ID="mycontent"> sample content
</asp:contentplaceholder>




</form>

</body>

</html>

The UserControl reads out a session-variable and displays it.

Then there is a page which uses the masterpage. It modifies the value of the
session-var if a button on the page is clicked and a postback is done.

The usercontrol displays the old value and not the new! Only after a new
postback (or a reload of the page) the correct value is displayed.
In the Page_Load function of the usercontrol is not written: "DataBind();"

How can I resolve this problem?

Thanks,
Alex
 
R

Remy

I would assume that the Master Page is processed before the normal
page. Don't really have the solution though. Maybe if you use OnInit()
instead of Page_Load() to do it? Sorry, just a shot into the dark...
But please let me know if you find the answer, would be interesting.

Remy Blaettler
www.collaboral.com
 
A

Alexander Widera

I found a solution...
I changed the Page_Load content of the UserControl to an other
function(-name), e.g. "updatebasket" , and let the Page_Load call this.
And then I created a function in the masterpage which calls this function
(updatebasket).
The click on the button now causes the change of the data in the
sessionvar
and calls the function in the masterpage which calls the updatebasket.
It is a solution ... perhaps not the best.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top