How to post a variable using a hidden textbox and retrieve it in another form?

Posted on 2008-10-17
Last Modified: 2008-10-18
I am trying to post a textbox value using a hidden variable and retrieve it in another form.
I am trying the following code but it is not printing anything. Could you please guide me regarding this?
Thanks for the help!

protected void Page_Load(object sender, EventArgs e)
            string confirmnumber;
            confirmnumber = Request.Form["confHidden"];
Question by:ipjyo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22746806
LVL 13

Assisted Solution

TechTiger007 earned 200 total points
ID: 22747431
Try this

protected void Page_Load(object sender, EventArgs e)
            string confirmnumber;
            HiddenField field = (HiddenField)PreviousPage.FindControl("confHidden");
            confirmnumber = field.value;

LVL 26

Accepted Solution

Anurag Thakur earned 300 total points
ID: 22747611
TechTiger i think that PreviousPage.FindControl works with cross page postbacks only (i think as i havent worked with that)

Cross-Page Posting in ASP.NET Web Pages

How to: Pass Values Between ASP.NET Web Pages

Author Comment

ID: 22748298
Now I am trying session and the following code. But it is giving an error
"Object reference not set to an instance of object". Please guide me if you have any idea of this.

protected void Page_Load(object sender, EventArgs e)
            string confirmnumber = null;
             if (Session["RecordLocator"]!=null)
             confirmnumber = (string)Session["RecordLocator"];
            confirmNoLabel.Text = confirmnumber.ToString();

Author Comment

ID: 22748331
Now it is working..thank you for the help

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unlocking a column in excel using C# 17 28 Markup for Sub Menu 2 46
Json and ajax 1 22
c# ftp code 3 33
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question