How to post back in asp.net 2008?

Posted by anwarbesa-15403 under ASP.NET on 10/18/2012 | Points: 10 | Views : 874 | Status : [Member] | Replies : 3
Hi everybody..

I have this question..how to post back in asp.net 2008?

In fact, how I can transfer data from one page to another?

For example, if I have one text box to enter the name and one button to go to the next page.. and I want to transfer the name from the textbox which I entered to the label in next page.. what should I do?.. and where I put the code?



C is a sea.. and you are the sea of C!

Thanks & Regards



Responses

Posted by: Vasanthmvp on: 10/18/2012 [Member] Starter | Points: 25

Up
0
Down
Hi, we have different ways to do this.

1. You can define a separate public class file with properties
public string textboxvalue {get;set;}
In the .aspx.cs of page with textbox, assign the value to this class property and use this wherever you need it. We call this as DTO

2.You can include the values into a session variable.
Session["MySession"]=txtid.Text; (txtid is the id of textbox).

3.You can pass the textbox value on to the querystring.
On click of the button, you are navigate to another page.
Include the NavigateUrl or Postbackurl of the button to "~/urnavigatingpage.aspx?UserName="+txtid.Text;
You can observe this value passing through the querystring in the address bar.
Get the query string value using
string txtvalue = Request.QueryString["UserName"].Value;

Regards,

Awesome Coding !! :)

anwarbesa-15403, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 10/21/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
Anwarbesa@Yahoo.Com

try this code

step1 Create Page1.aspx and page2.aspx

write the code page1.aspx
server side

protected void Page_Load(object sender, EventArgs e)
{

}
protected void Bt1_Click(object sender, EventArgs e)
{
Response.Redirect("Page2.aspx?Code="+Txta.Text +"");
}


Page2,aspx Code

protected void Page_Load(object sender, EventArgs e)
{
string str1 = Request.QueryString["Code"].ToString();
Response.Write(str1);

}



Mark as Answer if its helpful to you

anwarbesa-15403, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: anwarbesa-15403 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

Thanks dear brother Vasanthmvp..thanks dear brother Jayakumars

I will try the ways and codes..however I do this before ur replies..anyway thank to both of u so so much




C is a sea.. and you are the sea of C!

Thanks & Regards

anwarbesa-15403, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response