Click here to Skip to main content
15,913,300 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir/Ma'am

I am working in a .aspx site with vb as default language.

In first page name as Default.aspx.vb i have two textbox name as
TextBox1
TextBox2
I want to redirect the value of these Text box in to the
Textboxes find in second page name as Default2.aspx.

I give values 1 in the TextBox1 and afgh in the textbox2 of default.aspx page
and after redirecting i found value as 1afgh in the textbox 1 of Default2.aspx page
and textbox 2 of default2 remains empty.
while ans must be


1 in Textbox1(Of Defalt 2)
afgh in Text Box2 (Of Defalt 2)


I use the code as
url = "Default2.aspx?name=" & TextBox1.Text & " mail=" & TextBox2.Text
Posted

Think About Using the Session

Page : Default.aspx.vb



VB
Session("txtbox1") =  TextBox1.Text
Session("txtbox2") =  TextBox2.Text

Response.Redirect("Default2.aspx")



Page : Default2.aspx.vb

VB
TextBox1.Text=Session("txtbox1")
TextBox2.Text=Session("txtbox2")
 
Share this answer
 
v3
Comments
ankur789 5-Feb-13 3:39am    
sir i m using vb as default language
ankur789 5-Feb-13 3:41am    
while i m using vb as a default language then how can i rediect two textbox values to another page
leeccorp 5-Feb-13 6:04am    
Their is nothing new in c# or Vb in redirecting

Just use the above code

Good Day
 
Share this answer
 
Comments
ankur789 5-Feb-13 3:46am    
Sir these links also give the solution with .cs (c#) dotnet.
But with vb.net problem is as it is.
hi, try these sample code below-

default.aspx.vb
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Partial Class Default1
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(sender As Object, e As EventArgs)

	End Sub
	
	Protected Sub Button1_Click(sender As Object, e As EventArgs)
		Dim c1 As New HttpCookie("click")
		Dim c2 As New HttpCookie("click1")

		c1.Value = TextBox1.Text
		c2.Value = TextBox2.Text
		c1.Expires = DateTime.Now.AddHours(1) 'cookiee validity of 1 hrs
		c2.Expires = DateTime.Now.AddHours(1) 'cookiee validity of 1 hrs
		Response.Cookies.Add(c1)
		Response.Cookies.Add(c2)
		Response.Redirect("Default2.aspx")
	End Sub


default2.aspx.vb

VB.NET
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Partial Class Default2
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(sender As Object, e As EventArgs)

		TextBox1.Text = Request.Cookies("Click").Value
		TextBox2.Text = Request.Cookies("Click1").Value
	End Sub

End Class


default.aspx

XML
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Data Enter</title>
    <style type="text/css">
        .style1
        {
            width: 275px;
            border-style: solid;
            border-width: 1px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <table cellpadding="2" class="style1">
            <tr>
                <td>
                    first name</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server" Width="142px"></asp:TextBox>
                </td>
            </tr>
             <tr>
                <td>
                  last name  </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server" Width="142px"></asp:TextBox>
                </td>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
                </td>
            </tr>
        </table>

    </div>
    </form>
</body>
</html>


default2.aspx

XML
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Cookie Show</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

        <br />
        <br />

        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

    </div>
    </form>
</body>
</html>


*codes are converted from c# to VB.net. and used cookiee to pass values.

I hope it helped.
 
Share this answer
 
Comments
ankur789 5-Feb-13 5:11am    
thankx it really help me
Abhishek Pant 5-Feb-13 5:13am    
you're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900