Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add text box in array one and pass it's value in second page by query string?


My HTML CODE IS GIVEN BELOW


ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TextBoxInLoop.aspx.cs" Inherits="TextBoxInLoop" %>

<!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></title>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
    
     Employee ID  
        <asp:TextBox ID="txtId" runat="server"></asp:TextBox>
        <br />
        <br />
        Employee Name 
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
        <br />
        <br />
        Employee Email 
        <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
        <br />
        <br />
        Contact Number 
        <asp:TextBox ID="txtCno" runat="server"></asp:TextBox>
        <br />
        <br />
 Address             
        <asp:TextBox ID="txtAdd" runat="server"></asp:TextBox>
        <br />
        <br />
        Qualification        
        <asp:TextBox ID="txtQua" runat="server" ontextchanged="TextBox6_TextChanged"></asp:TextBox>
        <br />
        <br />
        Company            
        <asp:TextBox ID="txtCo" runat="server"></asp:TextBox>
        <br />
        <br />
        Salary                 
        <asp:TextBox ID="txtSal" runat="server"></asp:TextBox>
    
    </div>
    </form>
</body>
</html>
Posted
Updated 20-Dec-11 23:16pm
v2
Comments
Sunasara Imdadhusen 21-Dec-11 5:21am    
added PRE tag for readability!
Janardan Pandey 21-Dec-11 5:38am    
what is this PRE tag
patil.ravi035 21-Dec-11 5:23am    
hi Clarify Your Question do you want to pass textbox value to next page?

Try this,

ASP.NET
<div id="div1">
       Name <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
       Mobile  <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /><asp:Button ID="Button1" runat="server" Text="Insert" OnClick="pass_QS" />
</div>


In page1.aspx.cs(button click event)

C#
protected void pass_QS(object sender, EventArgs e)
    {
                            
        ArrayList myAL1 = new ArrayList();
        myAL1.Add(TextBox1.Text.ToString());
        myAL1.Add(TextBox2.Text.ToString());
        string items = String.Join(",", ((string[])myAL1.ToArray(typeof(String))));
        string url = "Default3.aspx?items=" + items;
        Response.Redirect(url);
}


In page2.aspx.cs
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["items"].ToString() != null)
        {
           
            string[] items = Request.QueryString["items"].ToString().Split(',');
            ArrayList al = new ArrayList();
            foreach (string item in items)
            {
            al.Add(item);
            }
            string ss = al[0].ToString();
             Response.Write(ss);
      }
    }
 
Share this answer
 
v2
Comments
Janardan Pandey 22-Dec-11 3:27am    
Thanks a lot giving hint bt not printing all value in the second form.
Con u send me after some amendment.I thisnk it is in foreach loop.I tryed a lot bt not getting succed please help me.
Shobana16 22-Dec-11 3:41am    
If you add 8 textbox values in "myAL1" , you can get the values of them,by giving al[0],a1[1],a1[2],.....,a1[7] . After getting these values print this using response.write()..Like,

string ss2 = al[2].ToString();
Response.Write(ss2);
One Page
dim str as New ArrayList
str.insert(0,TextBox1.Text.trim)
str.insert(1,TextBox2.Text.trim)
str.insert(2,TextBox3.Text.trim)
cache("test")=str
response.redirect("page_name.aspx" )

Navigation Page

dim str as new ArrayList
str=cache("test")
TextBox1.Text=str.item(0)
 
Share this answer
 
Don't use array
use this
pass value
VB
session.add("emp_name",txtName).Text.trim)


retreive value
VB
dim emp_name as string=session("emp_name")
 
Share this answer
 
v3
Comments
Sunasara Imdadhusen 21-Dec-11 5:21am    
added PRE tag for readability!
Janardan Pandey 21-Dec-11 5:38am    
Ya i have done this but i want to know how to store textbox in an array and how to pass multiple value in array from onepage to another page using wuerystring ?
Hi,
IF you want to pass textbox value to nextpage by using Querystring try this

C#
string txtvalue1=textbox1.text;
Response.redirect("NextPage.aspx?xxxx="+txtvalue);

above code will send textbox values to next page

you can take value In NextPage.aspx

C#
string txtvalue2=Request.QueryString[xxxx].ToString();
 
Share this answer
 
Comments
Janardan Pandey 21-Dec-11 5:38am    
Ya i have done this but i want to know how to store textbox in an array and how to pass multiple value in array from onepage to another page using wuerystring ?

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