Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2004, 05:26 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to use URL encoding

Hello

I have been stuck.
http://www.event2.aspx?12

My understanding is that you can use Request.QueryString to get "12"

But I can't get it to work.

Event1.aspx:
Dim sEventID As String = dsTestEvent.Tables("TestEvent").Rows(0)("EventID")
Dim sName As String = dsTestEvent.Tables("TestEvent").Rows(0)("Name")

lblText.Text = "<a href='https//www.event2.aspx?" & sEventID & "'>" & sName & "</a>"

Event2.aspx:

Dim dr As DataRow
        If Request.QueryString("EventID") = dr("EventID") Then
            lblevent2.Text = dr("Desc")
        End If
        lblevent2.Text = "Sorry. no match found."

I get a blank.
What am I doing wrong?
 
Old August 9th, 2004, 07:09 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I think you should use

http://www.event2.aspx?eventid=12

Event1.aspx:
 lblText.Text = "<a href='https//www.event2.aspx?EventID=" & sEventID & "'>" & sName & "</a>"



Om Prakash
 
Old August 9th, 2004, 07:46 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When I changed that I get error:
System.NullReferenceException: Object reference not set to an instance of an object

At:
 If Request.QueryString("EventID") = dr("EventID") Then

What is my problem???

 
Old August 9th, 2004, 08:28 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Dim dr As DataRow
      If Request.QueryString("EventID") = dr("EventID") Then
            lblevent2.Text = dr("Desc")
        End If
        lblevent2.Text = "Sorry. no match found."

In the above code, dr("EventID") should refer to active dataset. I think this is causing problem.


Om Prakash
 
Old August 9th, 2004, 06:50 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default


This is my full code:
I have 2 pages Event1.aspx and Event2.aspx?EventID=1

Event2.aspx?EventID=1:
Dim dsTestEvent As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dsTestEvent = DB.GetTestEvent
        Me.DisplayEvent()
End Sub

Private Sub DisplayEvent()
Dim dr As DataRow
If Not dr Is Nothing Then
 If Request.QueryString("EventID") = dr("EventID") Then
                lblevent2.Text = dr("Desc")
            End If
        Else
            lblevent2.Text = "Sorry. no match found."
        End If

Now I don't get blank and I get "Sorry. no match found."


I am very new to this Request.QueryString.

In Page load didn't I retrieve the dataset from DB class?
Dataset has three columns, name, eventid, and desc.
Doesn't that mean that I loaded the dataset???
Because there is only one table in dataset I don't have to explicitly call out the datatable right?

If I loaded the dataset then why isn't Request.QueryString("EventID") = dr("EventID")?

What is wrong?
Also people recommended that I haven't set dr. Did I not?
How would I do that here??

Thank you so much. Dougbe02 (Programmer)Aug 9, 2004Event1.aspx:
Dim dsTestEvent As DataSet
Dim dsEvent As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dsTestEvent = DB.GetTestEvent
        Me.K()
End Sub

Private Sub K()
Dim sEventID As String = dsTestEvent.Table("TestEvent").Rows(0)("EventID")
Dim sName As String = dsTestEvent.Tables("TestEvent").Rows(0)("Name")

lblText.Text = "<a href='https//www.event2.aspx?EventID=" & sEventID & "'>" & sName & "</a>"
End Sub

By the way in my DataSet there is only 1 row, EventID=1.
On Event1.aspx the link creates 'https//www.event2.aspx?EventID=1.
This is why I don't understand why in 'https//www.event2.aspx?EventID=1 page that dr doesn't match and instead I get "Sorry. no match found."


 
Old August 12th, 2004, 09:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Your url's are www.event2.aspx? How did you get them to add an .aspx TLD?

I think your URL's need some work here.

Why don't you put a debug statement to print out the Request.QueryString("EventID") on screen so you can see if it's getting the information properly from the Query String.

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old August 12th, 2004, 07:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

In displayevent, you don't get a row of data that I can see. Let me know if wrong. You need to get a row of data, because that routine would never be retrieved.

You need to do something like:

Private Sub DisplayEvent()
  if (dsTestEvent.Tables(0).Rows.Count > 0) then
    Dim dr As DataRow = dsTestEvent.Tables(0).Rows(0)
    If Not dr Is Nothing Then

Brian
 
Old August 12th, 2004, 10:35 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Got it Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
stop master page from url encoding solos ASP.NET 2.0 Basics 2 May 16th, 2008 12:37 PM
How do i encoding a url address kevo PHP How-To 3 July 17th, 2007 03:29 AM
problem in getting rid of '+' sign in url encoding vopatel Javascript How-To 0 May 21st, 2005 11:36 AM
URL encoding (why + and not %20?) dermotb XSLT 0 May 22nd, 2004 06:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.