Frage

I have a linkbutton in master page is as follows:

<ul class="links">
    <li class="first"><a href="NewsArchive.aspx" title="News">News</a></li>
    <li><a href="MyWishList.aspx" title="My Wishlist">My Wishlist</a></li>
    <li><a href="MainUserPage.aspx" title="My Account">My Account</a></li>
    <li class="last"><asp:LinkButton ID="LoginBTN" runat="server" onclick="LoginBTN_Click" Text="Login"></asp:LinkButton></li>
</ul>

And LoginBTN_Click is as follows:

protected void LoginBTN_Click(object sender, EventArgs e)
{
    if (LoginBTN.Text == "Login")
        Response.Redirect("Login.aspx");
    else
    {
        Session["IsAuthenticated"] = "False";
        Session["UserID"] = ""; Session["Name"] = ""; Session["Lname"] = ""; Session["Email"] = "";
        Session["Address"] = ""; Session["NewsLetter"] = ""; Session["UserStatus"] = ""; Session["LockUser"] = "";
        Session["LastLoginDate"] = ""; Session["Search"] = ""; Session["ShopingID"] = ""; Session["ChangePage"] = "";
        Session["Command"] = ""; Session["ContactID"] = ""; Session["SelectedIndex"] = ""; Session["LockUser"] = "";
        Session["UploadFileName"] = ""; Session["AgancyID"] = ""; Session["ReqCode"] = ""; Session["EditFlag"] = "";
        RegisterLBTN.CssClass = "";
        Response.Redirect("Default.aspx");
    }
}

and in Page_Load of master page is as follows:

if (!Page.IsPostBack)
{
   if (Session["IsAuthenticated"].ToString() == "True")
   {
      LoginBTN.Text = "Exit";
   }
}

when i run web site locally, Everything runs fine but when i run website on net, my linkbutton click event is not fired. But it is surprising to say When I'm on the registration page(register.aspx, NewsArchive.aspx, ... does not matter) and click on linkbutton, my code is work and redirect to login.aspx page.

I do not know exactly where the problem is?

War es hilfreich?

Lösung

There is a simple solution:

LoginLBTN.PostBackUrl = Request.Url.AbsoluteUri;

add this code in your Page_Load().

best regards

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top