Solved

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

Posted on 2008-10-17
5
508 Views
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"];
            Response.Write(confirmnumber);
               
       }
0
Comment
Question by:ipjyo
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22746806
0
 
LVL 13

Assisted Solution

by:TechTiger007
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;
            Response.Write(confirmnumber);
               
       }


0
 
LVL 26

Accepted Solution

by:
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
http://msdn.microsoft.com/en-us/library/ms178139(VS.80).aspx

How to: Pass Values Between ASP.NET Web Pages
http://msdn.microsoft.com/en-us/library/6c3yckfw(VS.80).aspx
0
 

Author Comment

by:ipjyo
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.
Thanks

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

Author Comment

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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now