Board index » Web Programming » updateproblem with usercontrol, page and masterpage

updateproblem with usercontrol, page and masterpage

Web Programming273
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


-
 

Re:updateproblem with usercontrol, page and masterpage

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



-

Re:updateproblem with usercontrol, page and masterpage

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.





"Remy" <rblaettler@hotmail.com>schrieb im Newsbeitrag

Quote
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







-