Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai friends,


I am having "Site1.master" page.In that page there is a logo and "Logout" hyperlink button.Suppose If i want to inherit this master page into other aspx pages it is inheriting but if we click on "Logout" in aspx page it is not redirecting the "Logout.aspx" page.Plz help me.Below is the code I have used.

"Site.Master"

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
    <link href="Styles/StyleSheet.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
   
</head>
<body>
    <form id="form1"  runat="server">
    <div>
   <table align="center" cellpadding="3" cellspacing="3">
       <img src="images/ul-new2.jpg" />
    
       
   </table>
   <table align="right">
   <tr>
   <td>
   <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Logout</asp:LinkButton>
   </td>
   </tr>
   </table>
   
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
       
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>


"Site.Master.cs"

protected void LinkButton1_Click(object sender, EventArgs e)
   {
       Response.Redirect("Logout.aspx");
   }


"Incident2.aspx"
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Incident2.aspx.cs" Inherits="Incident2" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<pre lang="xml"><table border="3" cellpadding="3" cellspacing="3" style="width:60%" align="center">
  <tr>
  <td align="right">
     <asp:Label ID="lblTitle" runat="server" Text="Title"></asp:Label>
  </td>
  <td>
  <asp:TextBox ID="txtTitle" runat="Server"  ></asp:TextBox>
  </td>
  </tr>






Thanks in advance
Posted
Comments
poorni_88 22-Jan-14 6:31am    
please explain the error in detail.

you mentioned that "logout.aspx" page is not redirecting. but you placed the code for incident2.aspx. Please make sure logout.aspx page is available.
Member 10234093 22-Jan-14 6:34am    
Ya."Logout.aspx" page is available.I am inheriting the master page into "incident2.aspx" page.

instead of using onclick in linkbutton

use


<asp:linkbutton id="LinkButton1" runat="server" postbackurl="~/Logout.aspx" xmlns:asp="#unknown">Logout
 
Share this answer
 
Comments
Member 10234093 22-Jan-14 6:33am    
still not working
Make sure that you have not done any logic in code behind of the site master or in the logout.cs file such a way that it will redirect to the default page (Incident2)..
 
Share this answer
 
Comments
Karthik_Mahalingam 22-Jan-14 6:49am    
Post your code behind of incident , logout, and sitemaster

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900