TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
narasiman rao
NA
519
771.5k
how to pass values to another page using query string
Aug 27 2012 6:45 AM
in design i have two pages.
in first design page i have two textboxes
Number1 10(textbox1)
Number2 12(textbox2)
first design page code as follows
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string number1 = Request.QueryString[0];
string number2 = Request.QueryString[1];
int result = Convert.ToInt32(number1) + Convert.ToInt32(number2);
//TextBox1.Text = result.ToString();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
string urltoNaviget = " ~/Add.aspx?Number1=" + txt_name.Text + "&Number2=" + txt_age.Text;
LinkButton1.PostBackUrl = urltoNaviget;
}
}
In Second design page i have one textbox
Adding Two numbers 22(textbox1)
Second
design page code as follows
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string number1 = Request.QueryString[0];
string number2 = Request.QueryString[1];
// The other way to Read the values
//string number1 = Request.QueryString["Number1"];
//string number2 = Request.QueryString["Number2"];
int result = Convert.ToInt32(number1) + Convert.ToInt32(number2);
TextBox1.Text = result.ToString();
}
}
When i run i have following error as follows
Index was out of range. Must be non-negative and less than the size of the collections.
Parameter name: index
Please help me
thanks,
Rao.,
Reply
Answers (
1
)
c# window application
Throw and Throw ex