hi every one,
how would i show my user name to another page top of the form using c# windows application?
that means form1 name is form1
and form2 name is form2,
in my first form1 is having login page,
for example,
my user name : TEST
password : TEST@123
my problem is how can i shifted to my user name to other page like session in asp.net but this is for windows application.
Actually i done the above process,please see my below code but its showing in the page itself, i dont want such a condition.
i need only to show my user name in the top of my second page, that is my form name,
here my form name is Form2.
so please find out my code below which i mentioned and give me an idea were i put change the code....
i have two form.
form1.cs:
see my below code....
private void btnlogin_Click(object sender, EventArgs e)
{
try
{
con = new SqlConnection(s);
con.Open();
cmd = new SqlCommand("select username,password from login",con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
string username = txtusername.Text;
string password = txtpassword.Text;
if (dr["username"].ToString() == username && dr["password"].ToString() == password)
{
Form2 hmpage = new Form2(username);
hmpage.Show();
this.Hide();
}
else
{
MessageBox.Show("The username or password you entered is incorrect!", "Logon Message!");
}
}
con.Close();
dr.Close();
}
catch (Exception ex)
{
}
}
Form2.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace tarriff_design_page
{
public partial class Home : Form
{
public Home(string strTextBox)
{
InitializeComponent();
label1.Text ="Welcome to:"+( strTextBox);
}
}
}
thanks in advance....