basically i have to pages like test.aspx and test1.aspx. test.aspx has one button and when button click then a routine is being called which will post data programmatically to test1.aspx page and test1.aspx page will show the data.
so here is the code for test.aspx page
protected void Button1_Click(object sender, EventArgs e)
{
PostForm();
}
private void PostForm()
{
WebRequest request = WebRequest.Create("http://localhost:14803/PaypalCSharp/Test1.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
string postContent = string.Format("parameter1={0}¶meter2={1}", "Hello", "Wow");
byte[] postContentBytes = Encoding.ASCII.GetBytes(postContent);
request.ContentLength = postContentBytes.Length;
Stream writer = request.GetRequestStream();
writer.Write(postContentBytes, 0, postContentBytes.Length);
writer.Close();
}
so here is the code for test1.aspx page
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string str1 = Request.Form["parameter1"];
string str2 = Request.Form["parameter2"];
}
}
i just do not understand what is wrong in my code as a result data is not posting to that page. basically i want that when user click on button in test.aspx then data will post from test.aspx page to test1.aspx page programmatically and test1.aspx will show in the browser with posted data. please guide me what i need to change in my code as a result my requirement will be fulfill. thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…