[英]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.