invoke order of page_Load and Linkbutton_Click in Template f
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
invoke order of page_Load and Linkbutton_Click in Template f

 
Post new topic   Reply to topic    Windows Server Forum Index -> CMS Server
Author Message
Nicole
Guest





Posted: Tue Oct 18, 2005 4:51 pm    Post subject: invoke order of page_Load and Linkbutton_Click in Template f Reply with quote

Hi,

This is what my program does:

I have

*Templatefile (template), with two HtmlPlaceholders (swedishPh and
englishPh)

*Usercontrol (control) with two linkbuttons (changeToEnglish and
changeToSwedish)

*SessionState["Lang"], Lang is en or sv.

When the changeToSwedish LinkButton is clicked, the Placeholder
swedishPh.Visible=true the englishPh.Visible=false and vice versa.

In template.Page_Load I check if (string)Session["Lang"] is "sv" or
"en"

The value is changed if LinkButtons are clicked:

private void changeToSwedish_Click(object sender, System.EventArgs e)
{
Session["Lang"] = "sv";
}

The problem is that when the LinkButton is clicked and the page is
reloaded, the Page_Load of the template is executed before the
changeToSwedish_Click.

That means the Session["Lang"] is not yet changed when the templates
Page_Load is executed, and the page is reloaded with the old value of
Session["Lang"] and the page is not updated until I click one of the
LinkButtons once again.

How do I solve this problem?

Best Regards,
Nicole
Back to top
Stefan [MSFT]
Guest





Posted: Tue Oct 18, 2005 4:51 pm    Post subject: Re: invoke order of page_Load and Linkbutton_Click in Templa Reply with quote

Hi Nicole,

that is by design of ASP.NET.
You should move the logic from the Page_Load event to the PreRender event.
Here it will work.

Cheers,
Stefan

--
This posting is provided "AS IS" with no warranties, and confers no rights

New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------


"Nicole" <nicole.zoger@lorensbergs.com> wrote in message
news:1129652960.874333.211390@g49g2000cwa.googlegroups.com...
Quote:
Hi,

This is what my program does:

I have

*Templatefile (template), with two HtmlPlaceholders (swedishPh and
englishPh)

*Usercontrol (control) with two linkbuttons (changeToEnglish and
changeToSwedish)

*SessionState["Lang"], Lang is en or sv.

When the changeToSwedish LinkButton is clicked, the Placeholder
swedishPh.Visible=true the englishPh.Visible=false and vice versa.

In template.Page_Load I check if (string)Session["Lang"] is "sv" or
"en"

The value is changed if LinkButtons are clicked:

private void changeToSwedish_Click(object sender, System.EventArgs e)
{
Session["Lang"] = "sv";
}

The problem is that when the LinkButton is clicked and the page is
reloaded, the Page_Load of the template is executed before the
changeToSwedish_Click.

That means the Session["Lang"] is not yet changed when the templates
Page_Load is executed, and the page is reloaded with the old value of
Session["Lang"] and the page is not updated until I click one of the
LinkButtons once again.

How do I solve this problem?

Best Regards,
Nicole
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> CMS Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB