Hello I have a pretty simple code that sends session variables to a Default Page and that page takes the session variables and populates a gridview based on a sqldatasource but it doesnt seem to be working. Absolutely nothing happens when you click on a
date.
The menus are supposed to be visible and the Masterpage sends the Default page the two sesssion variables those two session variables are then used in the sqldatasource to load the gridview. I didnt think I needed any code on the Default page except for
the sqldatasource(Working) and the gridview binded.
First, the masterpage isn't sending anything to the default page, it just sets a session variable which could be viewed anywhere.
Your menus aren't going to be visible from the code you mention because right after you set their visibility, you do a redirect. That basically sets them back to the original condition. You would need to set another session variable to say if they should
be visible or not and set the menus in the masterpage based upon the session variable to control them. So in essence, your code is working, but since you redirect immediately after making things visible, the settings are back to their original state.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
Code_warrior...
Member
251 Points
282 Posts
Masterpage to Default
Apr 30, 2012 08:01 PM|LINK
Hello I have a pretty simple code that sends session variables to a Default Page and that page takes the session variables and populates a gridview based on a sqldatasource but it doesnt seem to be working. Absolutely nothing happens when you click on a date.
Masterpage
protected void Calendar1_SelectionChanged1(object sender, EventArgs e) { MnuLeft.Visible=true; MnuRight.Visible=true; DateTime date = Calendar1.SelectedDate; Session["dete"] = date.ToShortDateString(); Session["Forum"] = "News"; Response.Redirect("Default.aspx", true); }march11
Contributor
2981 Points
1350 Posts
Re: Masterpage to Default
Apr 30, 2012 08:08 PM|LINK
You don't show any code that reveals what is suppose to happen when someone clicks on a date.
Show your gridview as well.
Code_warrior...
Member
251 Points
282 Posts
Re: Masterpage to Default
Apr 30, 2012 08:16 PM|LINK
The menus are supposed to be visible and the Masterpage sends the Default page the two sesssion variables those two session variables are then used in the sqldatasource to load the gridview. I didnt think I needed any code on the Default page except for the sqldatasource(Working) and the gridview binded.
Code_warrior...
Member
251 Points
282 Posts
Re: Masterpage to Default
Apr 30, 2012 08:21 PM|LINK
Even the menus dont become visible.
markfitzme
Star
14399 Points
2225 Posts
Re: Masterpage to Default
Apr 30, 2012 09:11 PM|LINK
First, the masterpage isn't sending anything to the default page, it just sets a session variable which could be viewed anywhere.
Your menus aren't going to be visible from the code you mention because right after you set their visibility, you do a redirect. That basically sets them back to the original condition. You would need to set another session variable to say if they should be visible or not and set the menus in the masterpage based upon the session variable to control them. So in essence, your code is working, but since you redirect immediately after making things visible, the settings are back to their original state.
Code_warrior...
Member
251 Points
282 Posts
Re: Masterpage to Default
Apr 30, 2012 09:41 PM|LINK
Yes, but why is my gridview not showing?
march11
Contributor
2981 Points
1350 Posts
Re: Masterpage to Default
May 01, 2012 02:14 PM|LINK
Same reason, you are redirecting and there is no data binding taking place after the redirect.
Code_warrior...
Member
251 Points
282 Posts
Re: Masterpage to Default
May 01, 2012 07:56 PM|LINK
Okay this is what I have now and everything seems to be working except for the menus. They just wont become visible. Please help.
protected void Calendar1_SelectionChanged1(object sender, EventArgs e) { if (MnuLeft.Visible == false && MnuRight.Visible == false) { MnuLeft.Visible = true; MnuRight.Visible = true; } DateTime date = Calendar1.SelectedDate; Session["dete"] = date; Session["Forum"] = "News"; Response.Redirect("Default.aspx", true); } protected void Page_Load(object sender, EventArgs e) { }march11
Contributor
2981 Points
1350 Posts
Re: Masterpage to Default
May 01, 2012 08:47 PM|LINK
Post all of your asp code.
mavrick_101
Member
96 Points
64 Posts
Re: Masterpage to Default
May 01, 2012 10:01 PM|LINK
Can you read the values of the session variables on the default page after redirect?