hi... i am developing web application login/logout/web functions. i want to pass the username(when login) in textbox to another web form like"Welcome usernamehere "
plz help me... im newbie for asp.net c# sorry for my bad english. thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
waqas memonPosted Mar 21, 2013, 3:31 PM
Satyapriya NayakPosted Mar 21, 2013, 2:47 PM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Login_Page_Using_Stored_Procedure
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlParameter UserName, Password;
protected void btn_login_Click(object sender, EventArgs e)
{
UserName = new SqlParameter();
Password = new SqlParameter();
SqlConnection con = new SqlConnection(strConnString);
com=new SqlCommand();
com.Connection = con;
con.Open();
Session["UserName"] = TextBox_user_name.Text;
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "login_pro";
UserName.SqlDbType = SqlDbType.VarChar;
UserName.Size = 50;
UserName.ParameterName = "@UserName";
UserName.Value = TextBox_user_name.Text.ToString();
UserName.Direction = ParameterDirection.Input;
Password.SqlDbType = SqlDbType.VarChar;
Password.Size = 50;
Password.ParameterName = "@Password";
Password.Value = TextBox_password.Text.ToString();
Password.Direction = ParameterDirection.Input;
com.Parameters.Add(UserName);
com.Parameters.Add(Password);
int status;
status = Convert.ToInt16(com.ExecuteScalar());
if (status == 1)
{
Response.Redirect("Welcome.aspx");
}
else
{
lblmessage.Text = "Invalid UserName and Password...";
}
con.Close();
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Welcome.aspx.cs" Inherits="Login_Page_Using_Stored_Procedure.Welcome" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Login_Page_Using_Stored_Procedure
{
public partial class Welcome : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "WELLCOME :: " + Session["UserName"];
}
}
}