Hi All,
I want to pass a string that contains many special characters (: \ . _
etc) to another page in my website
through query string.
In my project I have a Gridview control ,in which there is a hyperlink
field.The Gridview 's datasource is set as a database table at runtime.The
hyperlink filed's DataNavigateUrlFields is set to "RecordID" ,which is a
field in my database table.The RecordID field contains many special
characters.I want to pass the RecordID to PlayRecord.aspx page .I transfer
the RecordID by setting Hyperlink field's Data NavigateUrlFormat string as
PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not working as
RecordID contains special characters.(It works if RecordID is a normal
string).
Hope you 'll surely have a solution.
Thanking you in advance for your reply.
Best Regards

Re: How to pass special characters through query string ? by Anthony

Anthony
Tue May 20 02:09:36 CDT 2008

"Sobin Thomas" <sobin@securesonic.com> wrote in message
news:O59TnFkuIHA.4560@TK2MSFTNGP03.phx.gbl...
> Hi All,
> I want to pass a string that contains many special characters (: \ . _
> etc) to another page in my website
> through query string.
> In my project I have a Gridview control ,in which there is a hyperlink
> field.The Gridview 's datasource is set as a database table at runtime.The
> hyperlink filed's DataNavigateUrlFields is set to "RecordID" ,which is a
> field in my database table.The RecordID field contains many special
> characters.I want to pass the RecordID to PlayRecord.aspx page .I transfer
> the RecordID by setting Hyperlink field's Data NavigateUrlFormat string as
> PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not working
as
> RecordID contains special characters.(It works if RecordID is a normal
> string).
> Hope you 'll surely have a solution.
> Thanking you in advance for your reply.

This group is for Classic ASP. For ASP.NET questions post to
microsoft.public.dotnet.framework.aspnet


--
Anthony Jones - MVP ASP/ASP.NET



Re: How to pass special characters through query string ? by Bob

Bob
Tue May 20 06:13:02 CDT 2008

Sobin Thomas wrote:
> Hi All,
> I want to pass a string that contains many special characters (: \ . _
> etc) to another page in my website
> through query string.
> In my project I have a Gridview control ,in which there is a hyperlink
> field.The Gridview 's datasource is set as a database table at
> runtime.The hyperlink filed's DataNavigateUrlFields is set to
> "RecordID" ,which is a field in my database table.The RecordID field
> contains many special characters.I want to pass the RecordID to
> PlayRecord.aspx page .I transfer the RecordID by setting Hyperlink
> field's Data NavigateUrlFormat string as
> PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
> working as RecordID contains special characters.(It works if RecordID
> is a normal string).

The solution is the same for dotnet as it is for COM-based ASP: use the
urlEncode method to encode the strings being put into the querystring.
Having said that:

There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic (COM-based) asp newsgroup.
ASP.Net bears
very little resemblance to classic ASP so, while you may be lucky enough to
find a dotnet-knowledgeable person here who can answer your question, you
can eliminate the luck factor by posting your question to a group where
those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.aspnet or the forums at www.asp.net.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: How to pass special characters through query string ? by Anthony

Anthony
Tue May 20 14:53:29 CDT 2008

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:uewWypmuIHA.1316@TK2MSFTNGP06.phx.gbl...
> Sobin Thomas wrote:
> > Hi All,
> > I want to pass a string that contains many special characters (: \ . _
> > etc) to another page in my website
> > through query string.
> > In my project I have a Gridview control ,in which there is a hyperlink
> > field.The Gridview 's datasource is set as a database table at
> > runtime.The hyperlink filed's DataNavigateUrlFields is set to
> > "RecordID" ,which is a field in my database table.The RecordID field
> > contains many special characters.I want to pass the RecordID to
> > PlayRecord.aspx page .I transfer the RecordID by setting Hyperlink
> > field's Data NavigateUrlFormat string as
> > PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
> > working as RecordID contains special characters.(It works if RecordID
> > is a normal string).
>
> The solution is the same for dotnet as it is for COM-based ASP: use the
> urlEncode method to encode the strings being put into the querystring.


How easy is that to achieve when databinding into a gridview? I don't use
the provided controls much myself. I suspect one would need to add a field
to the datasource that has the value UrlEncoded. Better would be to not use
such a value and use a numeric, hash or guid instead.

--
Anthony Jones - MVP ASP/ASP.NET



Re: How to pass special characters through query string ? by Bob

Bob
Tue May 20 15:18:19 CDT 2008

Anthony Jones wrote:
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:uewWypmuIHA.1316@TK2MSFTNGP06.phx.gbl...
>> Sobin Thomas wrote:
>>> Hi All,
>>> I want to pass a string that contains many special characters (:
>>> \ . _ etc) to another page in my website
>>> through query string.
>>> In my project I have a Gridview control ,in which there is a
>>> hyperlink field.The Gridview 's datasource is set as a database
>>> table at runtime.The hyperlink filed's DataNavigateUrlFields is set
>>> to "RecordID" ,which is a field in my database table.The RecordID
>>> field contains many special characters.I want to pass the RecordID
>>> to PlayRecord.aspx page .I transfer the RecordID by setting
>>> Hyperlink field's Data NavigateUrlFormat string as
>>> PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
>>> working as RecordID contains special characters.(It works if
>>> RecordID is a normal string).
>>
>> The solution is the same for dotnet as it is for COM-based ASP: use
>> the urlEncode method to encode the strings being put into the
>> querystring.
>
>
> How easy is that to achieve when databinding into a gridview? I
> don't use the provided controls much myself.

I hadn't really thought it through. I suppose he would have to use a
templatefield object rather than a boundfield object so the object can
be bound to the result of the UrlEncode function.

> I suspect one would
> need to add a field to the datasource that has the value UrlEncoded.

That's one of the options I was thinking of.

> Better would be to not use such a value and use a numeric, hash or
> guid instead.
>
I can't argue with that.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: How to pass special characters through query string ? by Mike

Mike
Wed May 21 08:22:45 CDT 2008


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:ulPPmaruIHA.3780@TK2MSFTNGP03.phx.gbl...
> Anthony Jones wrote:
>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:uewWypmuIHA.1316@TK2MSFTNGP06.phx.gbl...
>>> Sobin Thomas wrote:
>>>> Hi All,
>>>> I want to pass a string that contains many special characters (:
>>>> \ . _ etc) to another page in my website
>>>> through query string.
>>>> In my project I have a Gridview control ,in which there is a
>>>> hyperlink field.The Gridview 's datasource is set as a database
>>>> table at runtime.The hyperlink filed's DataNavigateUrlFields is set
>>>> to "RecordID" ,which is a field in my database table.The RecordID
>>>> field contains many special characters.I want to pass the RecordID
>>>> to PlayRecord.aspx page .I transfer the RecordID by setting
>>>> Hyperlink field's Data NavigateUrlFormat string as
>>>> PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
>>>> working as RecordID contains special characters.(It works if
>>>> RecordID is a normal string).
>>>
>>> The solution is the same for dotnet as it is for COM-based ASP: use
>>> the urlEncode method to encode the strings being put into the
>>> querystring.
>>
>>
>> How easy is that to achieve when databinding into a gridview? I
>> don't use the provided controls much myself.
>
> I hadn't really thought it through. I suppose he would have to use a
> templatefield object rather than a boundfield object so the object can
> be bound to the result of the UrlEncode function.
>

Or you could simply format the value in the control's RowDataBound event....

--
Mike Brind
Microsoft MVP - ASP/ASP.NET