简体   繁体   English

从Windows表单中的登录页面重定向

[英]Redirect From Login Page In Windows Form

Ok Guys i Have 2 pages one Login and One Page is the Form Registration I want that the Login Page should come first and only after Login succesfull it redirects to the Registration page. 好的,我有2个页面,一个登录名和一个页面是表单注册。我希望登录页面首先出现,并且只有在登录成功后才重定向到“注册”页面。 It was easy for me in the Web Approach using Session variables but when i am trying to do it in the Windows Application The Registration page is coming first and only after logout from Registration page then My whole thing is working correct. 在Web方式中使用Session变量对我来说很容易,但是当我尝试在Windows应用程序中进行操作时,首先出现“注册”页面,并且只有从“注册”页面注销后,我的整个工作才能正常进行。 But i want that on startup itself the Login page should come. 但是我希望启动时本身会出现登录页面。

This is the Code i wrote 这是我写的代码

//----THIS IS IN THE REGISTRATION PAGE
        public static string Admin="";
protected override void OnVisibleChanged(EventArgs e)
    {
        base.OnVisibleChanged(e);
        this.Visible = false;
    }
    private void Form1_Load(object sender, EventArgs e)
    {
        //--------------------------WORKS WHEN FORM IS LOADED
        //this.Visible=false;
        if (Admin == "")
        {
            this.Hide();
            LoginObject.Show();
            //this.Close();
        }
        else
        {
            Admin = LoginObject.AdminId();
            this.Show();
            FormLoaded();
        }
//--------------THIS IS IN LOGIN PAGE

public static string Admin="";
private void ButtonLogIn_Click(object sender, EventArgs e)
    {
        string AdminUserName = TextUserName.Text;
        string AdminPassword = TextPassword.Text;

        //--------------------------------VERIFY ADMIN 

        GetSetAdmin.AdminUserName = AdminUserName;
        GetSetAdmin.AdminPassword = AdminPassword;
        BusinessClassAdminLogin BusniessObject = new BusinessClassAdminLogin();
        string AdminAuthorised = BusniessObject.ValidateAdmin(GetSetAdmin);
        if (!AdminAuthorised.Contains("-1"))
        {
            //Session["Admin"] = AdminAuthorised;
            //Response.Redirect("EmpRegistration.aspx");
            Admin = AdminAuthorised;
            EmpRegistration EmpRegObject = new EmpRegistration();
            this.Hide();
            EmpRegObject.Show();
        }
        else
        {
            MessageBox.Show("UserName or Passowrd Dont Match");
        }
    }
//---------------------MAIN FUNCTIOn 
   static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        //Application.Run(new EmpRegistration());
        Application.Run(new Login());
    }

In main page instead of default set Login page as start page. 在主页而不是默认设置中,将“登录”页面设置为起始页面。 You can use the base form or singleton class for storing the login information. 您可以使用基本表单或单例类来存储登录信息。

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

相关问题 从IFrame重定向到登录页面 - Redirect to login page from IFrame 将用户重定向到另一个 web 应用程序的登录表单并等待来自页面的响应(令牌) - Redirect user to the login form of another web app and wait for a response(a token) from the page 在来自服务器的未经授权的响应中重定向到登录页面 - Redirect to login page on unaothorized response from the server 将当前页面重定向到 Windows 表单 Web 浏览器上的另一个页面 - Redirect current page to another page on windows form web browser 如何将用户从登录表单重定向到c#中的另一个表单 - How to Redirect The User From Login Form to Another Form in c# 如何从网页重定向到Windows应用程序? - How to redirect from web page to windows application? 单击按钮-重定向到Windows窗体中的UserControl.cs页面 - Button click - redirect to UserControl.cs page in Windows Form 我们可以通过登录按钮从登录页面(非内容页面)重定向到母版页吗? - Can we redirect from login page(non content page) to master page via login button? 从Web-Api重定向到Login.aspx页面 - Redirect to Login.aspx Page from Web-Api 如何从ASP NET Core中的AuthorizationFilter重定向到登录页面? - How to redirect to login page from AuthorizationFilter in asp net core?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM