Masterpage to Defaulthttp://forums.asp.net/t/1798631.aspx/1?Masterpage+to+DefaultMon, 07 May 2012 02:46:08 -040017986314958906http://forums.asp.net/p/1798631/4958906.aspx/1?Masterpage+to+DefaultMasterpage to Default <p>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.</p> <p><strong>Masterpage</strong></p> <pre class="prettyprint">protected void Calendar1_SelectionChanged1(object sender, EventArgs e) { MnuLeft.Visible=true; MnuRight.Visible=true; DateTime date = Calendar1.SelectedDate; Session[&quot;dete&quot;] = date.ToShortDateString(); Session[&quot;Forum&quot;] = &quot;News&quot;; Response.Redirect(&quot;Default.aspx&quot;, true); }</pre> <p></p> <p>&nbsp;</p> 2012-04-30T20:01:26-04:004958912http://forums.asp.net/p/1798631/4958912.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>You don't show any code that reveals what is suppose to happen when someone clicks on a date.</p> <p>Show your gridview as well.</p> <p>&nbsp;</p> 2012-04-30T20:08:01-04:004958927http://forums.asp.net/p/1798631/4958927.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>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&nbsp;except for the sqldatasource(Working) and the gridview binded.</p> 2012-04-30T20:16:21-04:004958937http://forums.asp.net/p/1798631/4958937.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Even the menus dont become visible.</p> 2012-04-30T20:21:43-04:004958982http://forums.asp.net/p/1798631/4958982.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>First, the masterpage isn't sending anything to the default page, it just sets a session variable which could be viewed anywhere.</p> <p>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.</p> 2012-04-30T21:11:46-04:004959005http://forums.asp.net/p/1798631/4959005.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Yes, but why is my gridview not showing?</p> 2012-04-30T21:41:03-04:004960023http://forums.asp.net/p/1798631/4960023.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Same reason, you are redirecting and there is no data binding taking place after the redirect.</p> 2012-05-01T14:14:05-04:004960513http://forums.asp.net/p/1798631/4960513.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Okay this is what I have now and everything seems to be working except for the menus. They just wont become visible. Please help.</p> <p>&nbsp;</p> <pre class="prettyprint">protected void Calendar1_SelectionChanged1(object sender, EventArgs e) { if (MnuLeft.Visible == false &amp;&amp; MnuRight.Visible == false) { MnuLeft.Visible = true; MnuRight.Visible = true; } DateTime date = Calendar1.SelectedDate; Session[&quot;dete&quot;] = date; Session[&quot;Forum&quot;] = &quot;News&quot;; Response.Redirect(&quot;Default.aspx&quot;, true); } protected void Page_Load(object sender, EventArgs e) { }</pre> <p></p> <p>&nbsp;</p> 2012-05-01T19:56:19-04:004960565http://forums.asp.net/p/1798631/4960565.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Post all of your asp code.</p> 2012-05-01T20:47:03-04:004960603http://forums.asp.net/p/1798631/4960603.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Can you read the values of the session variables on the default page after redirect?</p> 2012-05-01T22:01:01-04:004960617http://forums.asp.net/p/1798631/4960617.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p><strong>Default.cs</strong></p> <pre class="prettyprint">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DateTime dt = Convert.ToDateTime(Session[&quot;dete&quot;]); Page.Master.EnableViewState = true; lblForumName.Text = Convert.ToString(dt); lblLatest.Text = Convert.ToString(Session[&quot;Forum&quot;]); }</pre> <p><strong>Main.master(Menus .Visibles set to false)</strong></p> <pre class="prettyprint">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DateTime dt = Convert.ToDateTime(Session[&quot;dete&quot;]); Page.Master.EnableViewState = true; lblForumName.Text = Convert.ToString(dt); lblLatest.Text = Convert.ToString(Session[&quot;Forum&quot;]); }</pre> <p><br /><strong>Default.aspx</strong></p> <pre class="prettyprint">&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"&gt; &lt;style type="text/css"&gt; .style4 { height: 31px; } &lt;/style&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt; &lt;table class="style1"&gt; &lt;tr&gt; &lt;td width="17%" class="style4"&gt; &lt;/td&gt; &lt;td class="style4"&gt; &amp;nbsp;&lt;/td&gt; &lt;td width="17%" class="style4"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt; &lt;table class="style1"&gt; &lt;tr&gt; &lt;td width="60%"&gt; &lt;asp:Label ID="lblForumName" runat="server" Font-Size="X-Large"&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td width="40%"&gt; &lt;asp:Label ID="lblLatest" runat="server" Font-Size="Larger"&gt;Latest&lt;/asp:Label&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="style2"&gt; &amp;nbsp;&lt;/td&gt; &lt;td class="style2"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/asp:Content&gt; </pre> <p><br> &nbsp;</p> <p><strong></strong></p> 2012-05-01T22:33:03-04:004960618http://forums.asp.net/p/1798631/4960618.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p></p> <blockquote><span class="icon-blockquote"></span> <h4>mavrick_101</h4> <p></p> <p>Can you read the values of the session variables on the default page after redirect?</p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>Yes I can see it.</p> 2012-05-01T22:34:51-04:004960656http://forums.asp.net/p/1798631/4960656.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>But the menus just wont show up.</p> 2012-05-02T00:49:59-04:004961234http://forums.asp.net/p/1798631/4961234.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Hi,</p> <p>As pointed out by others, youre doing a redirect to another page after setting the menu to visible. This will revert the menus Visible property to its original state. So if you set its Visible to false in the markup, it will remain invisible. The workflow is:</p> <p>Calendar1_SelectionChanged1 is invoked<br> You set menus Visible to true<br> You do a redirect<br> The markup of your master page is parsed<br> In the markup, you set menus Visible to false</p> <p>In the end, the menu is invisible.</p> <p>I would like to suggest you to put the code setting menus Visible in OnLoad on the second page instead of the SelectionChanged event handler. That essentially adds another step to the above workflow:</p> <p>In OnLoad of the second page, you set the menus Visible to true</p> <p>&nbsp;</p> <p>Best Regards,</p> <p>Ming Xu.</p> 2012-05-02T08:46:20-04:004962482http://forums.asp.net/p/1798631/4962482.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>I did what you suggested but now I dont see my labels displaying my session variables. The menus appear though. All I did was change the Default.cs to</p> <pre class="prettyprint">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DateTime dt = Convert.ToDateTime(Session[&quot;dete&quot;]); Page.Master.EnableViewState = true; lblForumName.Text = Convert.ToString(dt); lblLatest.Text = Convert.ToString(Session[&quot;Forum&quot;]); } protected override void OnLoad(EventArgs e) { Menu lMenu = (Menu)Master.FindControl(&quot;MnuLeft&quot;); Menu rMenu = (Menu)Master.FindControl(&quot;MnuRight&quot;); if (lMenu.Visible == false &amp;&amp; rMenu.Visible == false &amp;&amp; Session[&quot;dete&quot;] != null) { lMenu.Visible = true; rMenu.Visible = true; } }</pre> <p></p> 2012-05-02T18:48:25-04:004963156http://forums.asp.net/p/1798631/4963156.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Hi,</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Code_warriors</h4> I did what you suggested but now I dont see my labels displaying my session variables. The menus appear though. </blockquote> <p></p> <p>When you debug into the code, do you see the session data are available?</p> <p>&nbsp;</p> <p>Best Regards,</p> <p>Ming Xu.</p> 2012-05-03T07:15:43-04:004964337http://forums.asp.net/p/1798631/4964337.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>I took out the &quot;override&quot;&nbsp;out of&nbsp;the OnLoad event signature and now the menus dont show up but I have access to my session variables so I'm going to have to say yes they are available.</p> 2012-05-03T18:51:03-04:004964395http://forums.asp.net/p/1798631/4964395.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>What am I missing? Please help.</p> 2012-05-03T19:54:14-04:004967265http://forums.asp.net/p/1798631/4967265.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Boy do I miss the good old days of asp.net.</p> 2012-05-05T21:10:47-04:004968067http://forums.asp.net/p/1798631/4968067.aspx/1?Re+Masterpage+to+DefaultRe: Masterpage to Default <p>Hi,</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Code_warriors</h4> <p></p> <p>Boy do I miss the good old days of asp.net.</p> <p></p> </blockquote> <p></p> <p>To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it. Then we can find the issue more conveniently and provide further suggestions for you.<br> I would recommend that you can use <a href="http://explore.live.com/windows-live-skydrive"> Windows Live SkyDrive </a>to share the sample project.</p> <p>&nbsp;</p> <p>Best Regards,</p> <p>Ming Xu.</p> 2012-05-07T02:46:08-04:00