Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to send multiple value at a time of multiple text box from one page to orher page ?

Example - one Web page have 8 Text Boxs and send all text value to second page
Posted

send through query string. use URL like this.

C#
string URL = "page2.aspx?val1=" + txtbox1.Text + "&Val2=" + txtbox2.Text + "&Val3=" + txtbox3.Text + "&Val4=" + txtbox4.Text + "";


hope this helps..
 
Share this answer
 
Comments
thatraja 20-Dec-11 6:22am    
5! What about other options, see my answer
Monjurul Habib 20-Dec-11 12:53pm    
5!
Dear Friend,

You can make a loop on no of text boxes and can store their values at different indexes of the string array (string[] arr) and then can send you array as query string to the next page.

In the next page you can check that whether the Query String is empty or not and then type cast the Request.QueryString["arr"] to string array like :-

string[] arrNexForm=(string[])Request.QueryString["arr"].


Although i haven't tried it yet but still i think that it will work.

Try it and mark this as your answer if it is correct.

Thanks

Varun Sareen
 
Share this answer
 
v2
Comments
RaviRanjanKr 20-Dec-11 5:11am    
[Edited]Code is wrapped by pre and Code block[/Edited]
thatraja 20-Dec-11 6:22am    
5! What about other options, see my answer
 
Share this answer
 
Comments
thatraja 20-Dec-11 6:23am    
I like that MSDN link, 5!
What about other options, see my answer
RaviRanjanKr 20-Dec-11 14:18pm    
Thanks :)
Monjurul Habib 20-Dec-11 12:53pm    
5!
RaviRanjanKr 20-Dec-11 14:18pm    
Thanks :)
Try this,

In Default1.aspx
ASP.NET
<asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" xmlns:asp="#unknown" />


In Default1.aspx.cs
C#
 protected void btnSubmit_Click(object sender, EventArgs e)
{
string url = "Default2.aspx?text1=" + TextBox1.Text.ToString() + "&text2=" + TextBox2.Text.ToString()+"&text3=" + TextBox3.Text.ToString()+ "&text4="+ TextBox4.Text.ToString()+ "&text5="+ TextBox5.Text.ToString()+ "&text6="+ TextBox6.Text.ToString()+ "&text7="+ TextBox7.Text.ToString()+ "&text8="+ TextBox8.Text.ToString();

Response.Redirect(url);
}

In Default2.aspx.cs

C#
string text1, text2, text3, text4, text5, text6, text7, text8;
   protected void Page_Load(object sender, EventArgs e)
   {
       if (Request.QueryString["text1"].ToString() != null)
       {
           text1 = Request.QueryString["text1"].ToString();
       }
       if (Request.QueryString["text2"].ToString() != null)
       {
           text2 = Request.QueryString["text2"].ToString();
       }
       if (Request.QueryString["text3"].ToString() != null)
       {
           text3 = Request.QueryString["text3"].ToString();
       }
       if (Request.QueryString["text4"].ToString() != null)
       {
           text4 = Request.QueryString["text4"].ToString();
       }
       if (Request.QueryString["text5"].ToString() != null)
       {
           text5 = Request.QueryString["text5"].ToString();
       }
       if (Request.QueryString["text6"].ToString() != null)
       {
           text6 = Request.QueryString["text6"].ToString();
       }
       if (Request.QueryString["text7"].ToString() != null)
       {
           text7 = Request.QueryString["text7"].ToString();
       }
       if (Request.QueryString["text8"].ToString() != null)
       {
           text8 = Request.QueryString["text8"].ToString();
       }
   }
 
Share this answer
 
Comments
Dalek Dave 20-Dec-11 5:34am    
Comprehensive answer!
thatraja 20-Dec-11 6:23am    
But What about other options? see my answer
thatraja 20-Dec-11 6:23am    
Clean 5! What about other options, see my answer
RaviRanjanKr 20-Dec-11 14:29pm    
5+
Make use of QueryString to pass data between web pages.
 
Share this answer
 
Comments
thatraja 20-Dec-11 6:24am    
5! What about other options, see my answer
 
Share this answer
 
Comments
koolprasad2003 20-Dec-11 6:21am    
To the point raja.5.
Karthik Harve 20-Dec-11 6:26am    
My 5!
Monjurul Habib 20-Dec-11 12:52pm    
5!
Use state Management technique.
StateManagement Suggestions : A Beginner's View[^]
 
Share this answer
 

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