473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Empty parameters in a asp .net (vb) page query string

Hi,
I am trying to populate 3 paramters in an asp .net (vb) page redirect,
the first one is ok ok and gets populated by the other two get inserted into
the url for the redirect as empty strings! Anyone got any clues?? The code
is below and I have checked that the variables beginning with "g_str" are
all populated before the code is called. I think its something to do with
the "&" in the "&Title" and "&Version", do I need to do something to
those???

Cheers
Paul

Dim strVal_1 as string
Dim strVal_2 as string
Dim strVal_3 as string

strVal_1= "?SQL=" & g_strSQL
strVal_2= "&Title=" + g_strTitle
strVal_3= "&Version=" + g_strVersion

Response.Redirect("http://localhost/misc/frmEntry.aspx?Error=" & strVal_1 &
strVal_2 & strVal_3)
Jul 19 '05 #1
3 4929
Paul...I'm not sure but when you step through it in the debugger, I'm
assuming all the assignement are done correctl ( ie strVal_1, strVal_2 and
strVal3)

Try this...

Dim sb as New System.Text.Stringbuilder
sb.Append("http://localhost/misc/frmEntry.aspx?Error=")
sb.Append("?SQL=" & strSQL)
sb.Append("&Title=" & g_strTitle)
sb.Append("&Version=" & g_strVersion)
'Put breakpoint here to make sure redirect is what you want in it's
entirety - in the command window ?sb.ToSTring

Response.Redirect(sb.ToSTring)

It looks like the + might be the cause of improper string concatenation. In
either case, even if you don't use a stringbuilder, just add on all
concatenations with the line continue character _ b/c as it stands now,
you're creating at a minimum 3 string objects when one would do. (This
isn't the problem you are referring to, but it's just a suggestion for
efficiency's sake.)

Let me know if the full query string is getting populated correctly and if
so, we'll try to narrow it down from there.

Good Luck,

Bill

"Paul M." <pa**@nospam.fsnet.co.uk> wrote in message
news:bi**********@news6.svr.pol.co.uk...
Hi,
I am trying to populate 3 paramters in an asp .net (vb) page redirect,
the first one is ok ok and gets populated by the other two get inserted into the url for the redirect as empty strings! Anyone got any clues?? The code
is below and I have checked that the variables beginning with "g_str" are
all populated before the code is called. I think its something to do with
the "&" in the "&Title" and "&Version", do I need to do something to
those???

Cheers
Paul

Dim strVal_1 as string
Dim strVal_2 as string
Dim strVal_3 as string

strVal_1= "?SQL=" & g_strSQL
strVal_2= "&Title=" + g_strTitle
strVal_3= "&Version=" + g_strVersion

Response.Redirect("http://localhost/misc/frmEntry.aspx?Error=" & strVal_1 & strVal_2 & strVal_3)

Jul 19 '05 #2
"Paul M." <pa**@nospam.fsnet.co.uk> wrote in message
news:bi**********@news6.svr.pol.co.uk...
Hi,
I am trying to populate 3 paramters in an asp .net (vb) page redirect,
the first one is ok ok and gets populated by the other two get inserted into the url for the redirect as empty strings! Anyone got any clues?? The code
is below and I have checked that the variables beginning with "g_str" are
all populated before the code is called. I think its something to do with
the "&" in the "&Title" and "&Version", do I need to do something to
those???

Dim strVal_1 as string
Dim strVal_2 as string
Dim strVal_3 as string

strVal_1= "?SQL=" & g_strSQL
strVal_2= "&Title=" + g_strTitle
strVal_3= "&Version=" + g_strVersion

Response.Redirect("http://localhost/misc/frmEntry.aspx?Error=" & strVal_1 & strVal_2 & strVal_3)

Consider the resulting url :
http://.../frmEntry.aspx?Error=?SQL={value of g_strsql}&Title={value of
g_strtitle}&Version={value of g_strVersion}
The ? (Question mark) is used to separate the script name (ie: aspx page)
and the parameters and as you can see there are two question marks, thus
your url is malformed and the risk of a partial interpretation is high.
I don't know what is the purpose of the Error parameter, either it contains
all error fields or it is useless:
http://.../frmEntry.aspx?Error=?{value of g_strsql};{value of
g_strtitle};{value of g_strVersion}
In this url there is only one parameter: Error, then you have to split its
value to get error details.
http://.../frmEntry.aspx?SQL={value of g_strsql}&Title={value of
g_strtitle}&Version={value of g_strVersion}
This url is well formed and you should get correct values for the SQL, Title
and Version parameters.

Final note: the Sql and even Title parameters may contain unwanted
characters like ? or & that will again disturb the parsing of the url, it is
strongly recommended to encode the values so that they fit into an url.

The final code should look like :
strVal_1= "?SQL=" & Server.UrlEncode(g_strSQL)
strVal_2= "&Title=" & Server.UrlEncode(g_strTitle)
strVal_3= "&Version=" & g_strVersion

Response.Redirect("http://localhost/misc/frmEntry.aspx=" & strVal_1 &
strVal_2 & strVal_3)

DK

Jul 19 '05 #3
You probably need to URLEncode the variables.

You can look that up in the help system.

"William Ryan" <do********@nospam.comcast.net> wrote in message
news:uU*************@TK2MSFTNGP12.phx.gbl...
Paul...I'm not sure but when you step through it in the debugger, I'm
assuming all the assignement are done correctl ( ie strVal_1, strVal_2 and
strVal3)

Try this...

Dim sb as New System.Text.Stringbuilder
sb.Append("http://localhost/misc/frmEntry.aspx?Error=")
sb.Append("?SQL=" & strSQL)
sb.Append("&Title=" & g_strTitle)
sb.Append("&Version=" & g_strVersion)
'Put breakpoint here to make sure redirect is what you want in it's
entirety - in the command window ?sb.ToSTring

Response.Redirect(sb.ToSTring)

It looks like the + might be the cause of improper string concatenation. In either case, even if you don't use a stringbuilder, just add on all
concatenations with the line continue character _ b/c as it stands now,
you're creating at a minimum 3 string objects when one would do. (This
isn't the problem you are referring to, but it's just a suggestion for
efficiency's sake.)

Let me know if the full query string is getting populated correctly and if
so, we'll try to narrow it down from there.

Good Luck,

Bill

"Paul M." <pa**@nospam.fsnet.co.uk> wrote in message
news:bi**********@news6.svr.pol.co.uk...
Hi,
I am trying to populate 3 paramters in an asp .net (vb) page redirect, the first one is ok ok and gets populated by the other two get inserted into
the url for the redirect as empty strings! Anyone got any clues?? The code is below and I have checked that the variables beginning with "g_str" are all populated before the code is called. I think its something to do with the "&" in the "&Title" and "&Version", do I need to do something to
those???

Cheers
Paul

Dim strVal_1 as string
Dim strVal_2 as string
Dim strVal_3 as string

strVal_1= "?SQL=" & g_strSQL
strVal_2= "&Title=" + g_strTitle
strVal_3= "&Version=" + g_strVersion

Response.Redirect("http://localhost/misc/frmEntry.aspx?Error=" &

strVal_1 &
strVal_2 & strVal_3)


Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html>...
10
by: Adis | last post by:
Asp.Net Visual Studio 2003 SQL Server. Hi, Obtaining Data Based Upon Multiple Selections From a ListBox... I have database in Sqlserver and ListBox (Multiple Selection Mode) in my Visual...
4
by: Paul M. | last post by:
Hi, I am trying to populate 3 paramters in an asp .net (vb) page redirect, the first one is ok ok and gets populated by the other two get inserted into the url for the redirect as empty strings!...
0
by: jennifer.perkins | last post by:
I've seen a couple posts by people having similar problems, but the suggested solutions I've tried so far haven't worked. I'm using a SOAP client in VB.Net (constructed by wsdl.exe) and the...
3
by: eagleofjade | last post by:
I am trying to help a friend who is learning VB.net in school. I have done VB programming for a number of years using VB 6. He needs to open a query in an Access database that has parameters so he...
7
by: Aaron Gray | last post by:
I put together the following code to get the href's parameters :- function GetParameters() { var arg = new Object(); var href = document.location.href; if ( href.indexOf( "?") != -1) { var...
8
by: yawnmoth | last post by:
Say I have the following HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <form action="">
3
by: Haleigh | last post by:
I just started a few days ago, so I'm very new to this. I'm trying to update a gridview using a store procedure. When I am in the update subroutine, newvalues and oldvalues are empty, plus count is...
4
kcdoell
by: kcdoell | last post by:
Hello: What is the best way to stop a report from running if the query is empty? Currently, I have a form that has a command button on it. The user has to make selections from 3 combo boxes on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.