?
Solved

Passing variable from webform to webform

Posted on 2004-09-20
5
Medium Priority
?
313 Views
Last Modified: 2010-08-05
Trying to populate a ddl from a variable that got its value on a previous page

page one:     gmstrVendorRemitId = UCase(Trim(txtRemitID.Text))

page two:      ddlRemit.SelectedItem.Text = gmstrVendorRemitId

I get this error: Object reference not set to an instance of an object for page two.

Any ideas?

thanks,

6784

0
Comment
Question by:6784
[X]
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
5 Comments
 
LVL 6

Accepted Solution

by:
KGreg earned 800 total points
ID: 12104540
page one:

        Session.Add("VendorRemitId", UCase(Trim(txtRemitID.Text)))


page two:

        if not isnothing(session.Item("VendorRemitID") then

                ddlRemit.SelectedItem.Text = Session.Item("VendorRemitID")

        End If


KGreg
0
 

Author Comment

by:6784
ID: 12104847
I get the same error

this is my first ASP or ASP.NET application. I know nothing about Session. With the input of your code, thats the only place I use Session. From what I have seen in othe apps, I know this is wrong. Just don't understand the whole Session concept. Think I should stop coding and start reading.
0
 
LVL 2

Expert Comment

by:Mehrdad_Y
ID: 12104854
Hello
You have 3 ways to transfer data from one form to the other one:
1- Quary Strings: When you want to redirect user from one page to the other, use:
     Response.Redirect("http://PageTwo.aspx?VARIABLE1=VALUE1&VARIABLE2=VALUE2...")

    Then use the following code to get the value from the Quary String:
    Variable1=Me.Request.QuaryString("VARIABLE1")
    Variable2=Me.Request.QuaryString("VARIABLE2")
    ...
2- Cookies: Store data on the client machine:
    In page 1 write: Me.Response.Cookies.Add("VARIABLE1","VALUE1")
    In page 2 write: Variable1=Me.Request.Cookies("VARIABLE1").Value

3- Use Session or Application State:
    In Page 1 write: Session("Variable1")=Value1
    In Page 2 write: Variable2=Session("Variable2")

    Or use Application instead of Session.

Notes:
- In the third solution, anything stored in the session, will be only available for the current user, but if you store data in the Application, it will be available to all the users.
- The first solution has the best performance, but it sends data in clear text, and data is viewable from the addressbar.
- The second one, has a limit of capacity in the cookies (64K) and is not secure too, as the data is stored in the user's machine.
- The third one, is secure, as data is stored in the server, but has an effect of performance in heavy traffice environments.
0
 
LVL 6

Expert Comment

by:KGreg
ID: 12105610
this code is on page one:

        Session.Add("VendorRemitId", UCase(Trim(txtRemitID.Text)))


page two - AFTER THE PAGE IS LOADED.. you can't explicitly set the value of a control on a webform unless the page is loaded.. so this code has to be written in the codepage for page 2.. in the LOAD EVENT:

        if not isnothing(session.Item("VendorRemitID") then

                ddlRemit.SelectedItem.Text = Session.Item("VendorRemitID")

        End If

NOTE:  Session variables are probably more practical, because you don't want to let users control the flow of your application by encoding url's or cookies.


KGREG

0
 

Author Comment

by:6784
ID: 12106142
works now because I had the code wrong for populating the ddl.

thanks for the info Mehrdad_Y  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

771 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