Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing variable from webform to webform

Posted on 2004-09-20
5
Medium Priority
?
322 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
  • 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

Technology Partners: 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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

876 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