Hi indradeo,
For sending string value to another page you can use QueryString or Session.
Refer below example with both.
HTML
Default
Name:
<asp:TextBox ID="txtName" runat="server" Text="Mudassar Khan" />
<asp:Button ID="btnSendQueryString" Text="Send using QueryString" runat="server" OnClick="OnSendQueryString" />
<asp:Button ID="btnSendSession" Text="Send using Session" runat="server" OnClick="OnSendSession" />
Home
<asp:Label ID="lblName" runat="server" />
<br />
<asp:Button Text="Back" runat="server" OnClick="OnBack" />
Code
C#
Default
protected void OnSendQueryString(object sender, EventArgs e)
{
string name = txtName.Text;
Response.Redirect(string.Format("~/Home.aspx?name={0}", name));
}
protected void OnSendSession(object sender, EventArgs e)
{
Session["Name"] = txtName.Text;
Response.Redirect("~/Home.aspx");
}
Home
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Name"] != null)
{
lblName.Text = Session["Name"].ToString();
}
if (!string.IsNullOrEmpty(Request.QueryString["name"]))
{
lblName.Text = Request.QueryString["name"];
}
}
protected void OnBack(object sender, EventArgs e)
{
Response.Redirect("~/Default.aspx");
}
VB.Net
Default
Protected Sub OnSendQueryString(ByVal sender As Object, ByVal e As EventArgs)
Dim name As String = txtName.Text
Response.Redirect(String.Format("~/Home.aspx?name={0}", name))
End Sub
Protected Sub OnSendSession(ByVal sender As Object, ByVal e As EventArgs)
Session("Name") = txtName.Text
Response.Redirect("~/Home.aspx")
End Sub
Home
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Session("Name") IsNot Nothing Then
lblName.Text = Session("Name").ToString()
End If
If Not String.IsNullOrEmpty(Request.QueryString("name")) Then
lblName.Text = Request.QueryString("name")
End If
End Sub
Protected Sub OnBack(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("~/Default.aspx")
End Sub
Screenshot