Solved

Passing variable from webform to webform

Posted on 2004-09-20
5
311 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 200 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

Industry Leaders: 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 article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

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