<div class="wrapper"> <div class="header"> <Bewise:FlashControl ID="FlashControl1" runat="server" Height="300px" Loop="True" MovieUrl="~/Flash/AMs1.swf" SwLiveConnect="True" Width="1074px" /> </div> <div id="nav"> <div id="nav_wrapper"> <ul> <li><a href="Home.aspx">Home</a></li><li> <a href="Gallery.aspx">Gallery</a></li><li> <a href="AboutUs.aspx">About Us</a></li><li> <a href="ContactUs.aspx">Contact Us</a></li><li> <a href="Feedback.aspx">Feedback</a></li><li> <a href="Account.aspx">Account</a></li> </ul> <div id="Login" style="text-align: right; height: 0px; width: 85px;"> <asp:Label ID="lblLogin" runat="server" ForeColor="White" Text=""></asp:Label> <br /> <asp:LinkButton ID="LinkButton1" Font-Underline="false" CausesValidation="false" ValidationGroup="false" runat="server" ForeColor="White" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton> </div> </div> </div>
using System; using System.Linq; public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { using (AppointmentDataContext context = new AppointmentDataContext()) { // Checks if a user is logged in if (Session["login"] != null) { var query = (from p in context.Accounts where p.Email == Session["login"].ToString() select p.Name).FirstOrDefault(); lblLogin.Text = "Welcome " + query.Trim(); lblLogin.Visible = true; LinkButton1.Text = "Logout"; } else { lblLogin.Visible = false; LinkButton1.Text = "Login"; } } } protected void LinkButton1_Click(object sender, EventArgs e) { // User logs in if (LinkButton1.Text == "Login") { Response.Redirect("~/Login.aspx"); } else { // User logs out Session.Clear(); Response.Redirect("~/Home.aspx"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)