简体   繁体   English

我们可以通过登录按钮从登录页面(非内容页面)重定向到母版页吗?

[英]Can we redirect from login page(non content page) to master page via login button?

There should be login button and cancel button应该有登录按钮和取消按钮

Page should get to redirect to master page when submit button is clicked单击提交按钮时,页面应该重定向到母版页

try using this to redirect to the default page尝试使用它重定向到默认页面

protected void submitButton_Click(object sender, EventArgs e)
{
    Reponse.Redirec("~");
}

You have provided very little information for someone to give an accurate answer.您提供的信息很少,无法让某人给出准确答案。

  • I am assuming that the name of the master page to which you want to redirect on successful login is Master.aspx and furthermore this page is in root directory of your ASP.Net web app.我假设您要在成功登录时重定向到的母版页的名称是Master.aspx ,而且该页面位于您的 ASP.Net Web 应用程序的根目录中。

  • Also, I am assuming that you have a Login method returning a bool value in your code-behind of login page that contains the logic for login process of a user and which accepts two parameters of user name and password.此外,我假设您有一个Login方法,在您的登录页面的代码隐藏中返回一个 bool 值,该值包含用户登录过程的逻辑,并接受用户名和密码这两个参数。

Then, you need to have code like below.然后,您需要具有如下代码。 You'll need to adapt this code to your requirements by replacing the user name text box id, password textbox id, login method name and master page name.您需要通过替换用户名文本框 ID、密码文本框 ID、登录方法名称和母版页名称来使此代码适应您的要求。

protected void loginButton_Click(object sender, EventArgs e)
{
    //txtUserName is textbox for inputting user name on login page
    //txtPwd is textbox for inputting password on login page
    bool isValidLogin = Login(txtUserName.Text, txtPwd.Text);
    if (isValidLogin) {
              Response.Redirect("~/Master.aspx");
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM