Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every one,
i am using vs2010,
i have to webforms in my project .
like webform1, webform2,
in webform1 have some text in lable and a button.
in Webform2 have one lable when click on button in webform1 then to transfer a webform1 label text into webform2 label.
for that i am using like this.........


in webform1 buttin click

C#
protected void BtnOne_Click(object sender, EventArgs e)
{
    Response.Redirect("WebForm2.aspx");
}


in webform2.aspx.cs
C#
protected void Page_Load(object sender, EventArgs e)
        {
    TextBox1.Text = HttpContext.Current.Request.Form["form1"].ToString();
         }


it's not working
note: without using sessions,cookies,application[data]......only to use HttpContext
suggestions would be appreciated!
Thanks in advance,
naresh
Posted
Comments
Mario Majčica 20-Aug-12 8:27am    
Why wouldn't you use session or QueryString?
Unareshraju 20-Aug-12 8:29am    
this data passing into third party server, so i avoid sessions....

Hi,

Based on comment's, here is my suggestion;
As you are leaving your IIS context, the only way to pass information directly to the form is by using a QueryString. Here can you find an article about it

Passing variables between pages using QueryString[^]

Cheers
 
Share this answer
 
Comments
Unareshraju 20-Aug-12 8:53am    
thanks a lot for your reply,
i am using only using HttpContext, please look at over .....
Unareshraju 20-Aug-12 8:58am    
could you look here :
http://msdn.microsoft.com/en-us/library/system.web.ui.page.context.aspx
Mario Majčica 20-Aug-12 9:06am    
You sad that you are trying to redirect to a page on a different server. The context is applied on IIS instance of your app.
Hi,

You can use Page.PreviousPage to get previous page control information,

Here is an example taken from Here @MSDN[^]

C#
if (Page.PreviousPage != null)
{
    TextBox SourceTextBox =
        (TextBox)Page.PreviousPage.FindControl("TextBox1");
    if (SourceTextBox != null)
    {
        Label1.Text = SourceTextBox.Text;
    }
}



Hope it helps you,

Thanks
-Amit Gajjar
 
Share this answer
 
Comments
Unareshraju 20-Aug-12 23:37pm    
hi amit, is there any way by using HttpContext ?
AmitGajjar 20-Aug-12 23:58pm    
why you want to use HttpContext any reason ? i don't know any way with HttpContext.
Unareshraju 23-Aug-12 1:52am    
hi amit thanks a lot, i am passing a file through the web service into external server . So for that reason i am using HttpContext.
AmitGajjar 23-Aug-12 3:23am    
can't you pass value along with file in your service?

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