注销超链接按钮c#中.aspx页面中的导航错误 [英] Logout hyperlink button Navigation error in .aspx page in c#

查看:74
本文介绍了注销超链接按钮c#中.aspx页面中的导航错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai friends,





我有Site1.master页面。在该页面上有一个徽标和Logout 超链接按钮。假设如果我想将这个母版页继承到其他aspx页面继承,但如果我们点击aspx页面中的Logout,它就不会重定向Logout.aspx页面.Plz帮助我。下面是我用过的代码。



Site.Master



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





"Site.Master.cs"

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





Incident2.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

推荐答案

而不是在链接按钮中使用onclick



使用





< asp:linkbutton id =LinkBut​​ton1runat =serverpostbackurl =〜 /Logout.aspxxmlns:asp =#unknown> Logout
instead of using onclick in linkbutton

use


<asp:linkbutton id="LinkButton1" runat="server" postbackurl="~/Logout.aspx" xmlns:asp="#unknown">Logout


确保您没有在站点主站或注销后面的代码中做任何逻辑.cs文件这样一种方式,它将重定向到默认页面(Incident2)..


这篇关于注销超链接按钮c#中.aspx页面中的导航错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆