Hello,
I have the following masterpage:
1 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="WebApplication1.Site1" %>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5 <html xmlns="http://www.w3.org/1999/xhtml" >
6 <head runat="server">
7 <title>Untitled Page</title>
8 <link href="Stylesheet1.css" rel="stylesheet" type="text/css" />
9 </head>
10 <body>
11 <div id="navigation">
12 <% if (Session["logged"] == "yes")
13 { %>
14 <ul>
15 <li>
16 logged
17 </li>
18 </ul>
19 <% } %>
20 </div>
21
22 <div id="content">
23 <asp:ContentPlaceHolder ID="MainContent" runat="server">
24
25 </asp:ContentPlaceHolder>
26 </div>
27 </body>
28 </html>
I also have a login.aspx file which looks like this:
1 <%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="WebApplication1.WebForm_login" Title="Untitled Page" %>
2 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
3 <form id="login_form" runat="server" method="post">
4 <% if ((string)Session["logged"] == "no")
5 {
6 login_div.Visible = true;
7 calendar_div.Visible = false;
8 }
9 else
10 {
11 login_div.Visible = false;
12 calendar_div.Visible = true;
13 } %>
14 <div id="login_div" runat="server">
15 <table border="0" cellpadding="0" cellspacing="2">
16 <tr>
17 <td colspan="2">
18 Please log in<br /><br />
19 </td>
20 </tr>
21 <tr>
22 <td>
23 <label for="username">Username:</label>
24 </td>
25 <td>
26 <asp:TextBox ID="username" TabIndex="1" runat="server"></asp:TextBox>
27 </td>
28 </tr>
29 <tr>
30 <td>
31 <label for="password">Password:</label>
32 </td>
33 <td>
34 <asp:TextBox ID="password" TabIndex="2" runat="server" TextMode="Password"></asp:TextBox>
35 </td>
36 </tr>
37 <tr>
38 <td>
39 <asp:Button ID="login_button" Text="Login" runat="server" OnClick="do_login" />
40 </td>
41 </tr>
42 </table>
43 </div>
44 <div id="calendar_div" runat="server">
45 <asp:Calendar ID="Calendar1" runat="server" BackColor="White"
46 BorderColor="Black" DayNameFormat="Shortest" Font-Names="Times New Roman"
47 Font-Size="10pt" ForeColor="Black" Height="220px" NextPrevFormat="FullMonth"
48 TitleFormat="Month" Width="400px">
49 <SelectedDayStyle BackColor="#CC3333" ForeColor="White" />
50 <SelectorStyle BackColor="#CCCCCC" Font-Bold="True" Font-Names="Verdana"
51 Font-Size="8pt" ForeColor="#333333" Width="1%" />
52 <TodayDayStyle BackColor="#CCCC99" />
53 <OtherMonthDayStyle ForeColor="#999999" />
54 <DayStyle Width="14%" />
55 <NextPrevStyle Font-Size="8pt" ForeColor="White" />
56 <DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt"
57 ForeColor="#333333" Height="10pt" />
58 <TitleStyle BackColor="Black" Font-Bold="True" Font-Size="13pt"
59 ForeColor="White" Height="14pt" />
60 </asp:Calendar>
61 </div>
62 </form>
63 </asp:Content>
64
Once logged in, the calendar div gets displayed and the login div becomes invisible as planned, my problem is that the menu contained in the master page does not get displayed at all although I set the Session["logged"] variable to "yes".
This is the code behind for loging in:
1 protected void do_login(object sender, EventArgs e)
2 {
3 String uname = username.Text;
4 String upass = EncryptPassword(password.Text);
5 string sql = "select * from tadminuser where username = :uname and passwrd = :upass";
6
7 NpgsqlCommand cmd = new NpgsqlCommand(sql, (NpgsqlConnection)Application["conn"]);
8 cmd.Parameters.Add(new NpgsqlParameter("uname", DbType.String));
9 cmd.Parameters.Add(new NpgsqlParameter("upass", DbType.String));
10 cmd.Parameters[0].Value = uname;
11 cmd.Parameters[1].Value = upass;
12 NpgsqlDataAdapter da = new NpgsqlDataAdapter(cmd);
13
14 // create dataset and give a name to it
15 DataSet ds = new DataSet("admin_user");
16
17 // fill the dataset using the dataadapter and give the table a name
18 da.Fill(ds, "admin_user");
19
20 // create a datatable and populate it with the table contained in the dataset
21 DataTable dt = ds.Tables["admin_user"];
22
23 if (dt.Rows.Count != 1)
24 {
25 Response.Write("The username and/or password may be incorrect<br />Please try again");
26 }
27 else
28 {
29 Session["logged"] = "yes";
30 }
31 }
Any idea why this is happening?
Thank you