p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: RE: problems with passing a name containing & cha racter


Message #1 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 19 Jun 2002 10:55:50 -0400
First, note that it is not valid HTML to write an ampersand without escaping
it.

<a href="mypage.asp?var1=x&var2=y">Invalid link</a>

The "&" between var1=x and var2=y must be escaped, and should be done like
this:

<a href="mypage.asp?var1=x&amp;var2=y">Valid link</a>

In your example, you have an ampersand before CustName that should be
re-written as &amp;

Now, to include the ampersand in the value of what you are sending, you will
want to URLEncode the value.  Like so:

&amp;CustName=<%=Server.URLEncode( ListCustomer("CustomerName") )%>">Add
Service</a>

The "&" in the customer name will be replaced with %26 in the URL, and the
browser will know that it's an ampersand in the name, and not the separator
between variables.

Hope this helps.
Peter


> -----Original Message-----
> From: Petr Novotny [mailto:pn@b...]
> Sent: Friday, June 14, 2002 7:51 AM
> To: ASP Databases
> Subject: [asp_databases] problems with passing a name 
> containing & character
> 
> 
> Hi,
> 
> I've encountered a problem and don't know how to go about it. 
> 
> I'm passing following string ....
> &CustName=<%=ListCustomer("CustomerName")%>">Add Service</a>
> 
> The problem is that the customer's name contain & .. AT&T .
> 
> Can you tell me what I need to do to pass it correctly?
> 
> Thanks
> 
> Petr
> 
> 
> > -----Original Message-----
> > From: Colin.Montgomery@C...
> > [mailto:Colin.Montgomery@C...]
> > Sent: Friday, June 14, 2002 12:49 PM
> > To: ASP Databases
> > Subject: [asp_databases] RE: popluate list box with values from a
> > database
> > 
> > 
> > you should use ASP to populate a JavaScript array containing 
> > the values and
> > text for the list box.  Then you need to write your onClick 
> handler in
> > JavaScript to fill the list box with these values.
> > 
> > HTH,
> > Col
> > 
> > -----Original Message-----
> > From: shawn mccabe [mailto:shawn_mccabe@c...]
> > Sent: 13 June 2002 23:29
> > To: ASP Databases
> > Subject: [asp_databases] popluate list box with values from 
> a database
> > 
> > 
> > How can I popluate a list box with values from a database on 
> > a onclick 
> > event.
> > I can poplate the list box when the asp page loads but not on 
> > the onclick 
> > event why and how do I accomplish this task.
> > 
> > 
> > *******
> > 
> > This message and any attachment are confidential and may be 
> > privileged or otherwise protected from disclosure.  If you 
> > are not the intended recipient, please telephone or email the 
> > sender and delete this message and any attachment from your 
> > system.  If you are not the intended recipient you must not 
> > copy this message or attachment or disclose the contents to 
> > any other person.
> > 
> > For further information about Clifford Chance please see our 
> > website at http://www.cliffordchance.com or refer to any 
> > Clifford Chance office.
> > 
> > 
> 
> 
Message #2 by <jparlato@m...> on Wed, 19 Jun 2002 10:59:49 -0400
You may need to use the server.urlencode() function on the data first.


On Wed, 19 Jun 2002 12:09:48 +0200 Kim Iwan Hansen <kimiwan@k...> wrote:

That shouldn't be a problem since it's part of a string and not the string
end tag.

It must be something else, so try and post some more code and an error
message.
(remember to indicate which line is the one the error message says is the
problem).

-Kim

> -----Original Message-----
> From: Petr Novotny [mailto:pn@b...]
> Sent: 14. juni 2002 13:51
> To: ASP Databases
> Subject: [asp_databases] problems with passing a name containing
> & character
>
>
> Hi,
>
> I've encountered a problem and don't know how to go about it.
>
> I'm passing following string ....
> &CustName=<%=ListCustomer("CustomerName")%>">Add Service</a>
>
> The problem is that the customer's name contain & .. AT&T .
>
> Can you tell me what I need to do to pass it correctly?
>
> Thanks
>
> Petr
>
>
> > -----Original Message-----
> > From: Colin.Montgomery@C...
> > [mailto:Colin.Montgomery@C...]
> > Sent: Friday, June 14, 2002 12:49 PM
> > To: ASP Databases
> > Subject: [asp_databases] RE: popluate list box with values from a
> > database
> >
> >
> > you should use ASP to populate a JavaScript array containing
> > the values and
> > text for the list box.  Then you need to write your onClick handler in
> > JavaScript to fill the list box with these values.
> >
> > HTH,
> > Col
> >
> > -----Original Message-----
> > From: shawn mccabe [mailto:shawn_mccabe@c...]
> > Sent: 13 June 2002 23:29
> > To: ASP Databases
> > Subject: [asp_databases] popluate list box with values from a database
> >
> >
> > How can I popluate a list box with values from a database on
> > a onclick
> > event.
> > I can poplate the list box when the asp page loads but not on
> > the onclick
> > event why and how do I accomplish this task.
> >
> >
> > *******
> >
> > This message and any attachment are confidential and may be
> > privileged or otherwise protected from disclosure.  If you
> > are not the intended recipient, please telephone or email the
> > sender and delete this message and any attachment from your
> > system.  If you are not the intended recipient you must not
> > copy this message or attachment or disclose the contents to
> > any other person.
> >
> > For further information about Clifford Chance please see our
> > website at http://www.cliffordchance.com or refer to any
> > Clifford Chance office.
> >
> >
>


Message #3 by "Kim Iwan Hansen" <kimiwan@k...> on Wed, 19 Jun 2002 12:09:48 +0200
That shouldn't be a problem since it's part of a string and not the string
end tag.

It must be something else, so try and post some more code and an error
message.
(remember to indicate which line is the one the error message says is the
problem).

-Kim

> -----Original Message-----
> From: Petr Novotny [mailto:pn@b...]
> Sent: 14. juni 2002 13:51
> To: ASP Databases
> Subject: [asp_databases] problems with passing a name containing
> & character
>
>
> Hi,
>
> I've encountered a problem and don't know how to go about it.
>
> I'm passing following string ....
> &CustName=<%=ListCustomer("CustomerName")%>">Add Service</a>
>
> The problem is that the customer's name contain & .. AT&T .
>
> Can you tell me what I need to do to pass it correctly?
>
> Thanks
>
> Petr
>
>
> > -----Original Message-----
> > From: Colin.Montgomery@C...
> > [mailto:Colin.Montgomery@C...]
> > Sent: Friday, June 14, 2002 12:49 PM
> > To: ASP Databases
> > Subject: [asp_databases] RE: popluate list box with values from a
> > database
> >
> >
> > you should use ASP to populate a JavaScript array containing
> > the values and
> > text for the list box.  Then you need to write your onClick handler in
> > JavaScript to fill the list box with these values.
> >
> > HTH,
> > Col
> >
> > -----Original Message-----
> > From: shawn mccabe [mailto:shawn_mccabe@c...]
> > Sent: 13 June 2002 23:29
> > To: ASP Databases
> > Subject: [asp_databases] popluate list box with values from a database
> >
> >
> > How can I popluate a list box with values from a database on
> > a onclick
> > event.
> > I can poplate the list box when the asp page loads but not on
> > the onclick
> > event why and how do I accomplish this task.
> >
> >
> > *******
> >
> > This message and any attachment are confidential and may be
> > privileged or otherwise protected from disclosure.  If you
> > are not the intended recipient, please telephone or email the
> > sender and delete this message and any attachment from your
> > system.  If you are not the intended recipient you must not
> > copy this message or attachment or disclose the contents to
> > any other person.
> >
> > For further information about Clifford Chance please see our
> > website at http://www.cliffordchance.com or refer to any
> > Clifford Chance office.
> >
> >
>

Message #4 by "Petr Novotny" <pn@b...> on Fri, 14 Jun 2002 13:51:24 +0200
Hi,

I've encountered a problem and don't know how to go about it. 

I'm passing following string ....
&CustName=<%=ListCustomer("CustomerName")%>">Add Service</a>

The problem is that the customer's name contain & .. AT&T .

Can you tell me what I need to do to pass it correctly?

Thanks

Petr


> -----Original Message-----
> From: Colin.Montgomery@C...
> [mailto:Colin.Montgomery@C...]
> Sent: Friday, June 14, 2002 12:49 PM
> To: ASP Databases
> Subject: [asp_databases] RE: popluate list box with values from a
> database
> 
> 
> you should use ASP to populate a JavaScript array containing 
> the values and
> text for the list box.  Then you need to write your onClick handler in
> JavaScript to fill the list box with these values.
> 
> HTH,
> Col
> 
> -----Original Message-----
> From: shawn mccabe [mailto:shawn_mccabe@c...]
> Sent: 13 June 2002 23:29
> To: ASP Databases
> Subject: [asp_databases] popluate list box with values from a database
> 
> 
> How can I popluate a list box with values from a database on 
> a onclick 
> event.
> I can poplate the list box when the asp page loads but not on 
> the onclick 
> event why and how do I accomplish this task.
> 
> 
> *******
> 
> This message and any attachment are confidential and may be 
> privileged or otherwise protected from disclosure.  If you 
> are not the intended recipient, please telephone or email the 
> sender and delete this message and any attachment from your 
> system.  If you are not the intended recipient you must not 
> copy this message or attachment or disclose the contents to 
> any other person.
> 
> For further information about Clifford Chance please see our 
> website at http://www.cliffordchance.com or refer to any 
> Clifford Chance office.
> 
> 
Message #5 by "Petr Novotny" <pn@b...> on Thu, 20 Jun 2002 08:27:48 +0200
Thanks everyone,

It works now!

Petr

> -----Original Message-----
> From: Peter Foti (PeterF) [mailto:PeterF@S...]
> Sent: Wednesday, June 19, 2002 4:56 PM
> To: ASP Databases
> Subject: [asp_databases] RE: problems with passing a name containing &
> cha racter
> 
> 
> First, note that it is not valid HTML to write an ampersand 
> without escaping
> it.
> 
> <a href="mypage.asp?var1=x&var2=y">Invalid link</a>
> 
> The "&" between var1=x and var2=y must be escaped, and should 
> be done like
> this:
> 
> <a href="mypage.asp?var1=x&amp;var2=y">Valid link</a>
> 
> In your example, you have an ampersand before CustName that should be
> re-written as &amp;
> 
> Now, to include the ampersand in the value of what you are 
> sending, you will
> want to URLEncode the value.  Like so:
> 
> &amp;CustName=<%=Server.URLEncode( 
> ListCustomer("CustomerName") )%>">Add
> Service</a>
> 
> The "&" in the customer name will be replaced with %26 in the 
> URL, and the
> browser will know that it's an ampersand in the name, and not 
> the separator
> between variables.
> 
> Hope this helps.
> Peter
> 
> 
> > -----Original Message-----
> > From: Petr Novotny [mailto:pn@b...]
> > Sent: Friday, June 14, 2002 7:51 AM
> > To: ASP Databases
> > Subject: [asp_databases] problems with passing a name 
> > containing & character
> > 
> > 
> > Hi,
> > 
> > I've encountered a problem and don't know how to go about it. 
> > 
> > I'm passing following string ....
> > &CustName=<%=ListCustomer("CustomerName")%>">Add Service</a>
> > 
> > The problem is that the customer's name contain & .. AT&T .
> > 
> > Can you tell me what I need to do to pass it correctly?
> > 
> > Thanks
> > 
> > Petr
> > 
> > 
> > > -----Original Message-----
> > > From: Colin.Montgomery@C...
> > > [mailto:Colin.Montgomery@C...]
> > > Sent: Friday, June 14, 2002 12:49 PM
> > > To: ASP Databases
> > > Subject: [asp_databases] RE: popluate list box with values from a
> > > database
> > > 
> > > 
> > > you should use ASP to populate a JavaScript array containing 
> > > the values and
> > > text for the list box.  Then you need to write your onClick 
> > handler in
> > > JavaScript to fill the list box with these values.
> > > 
> > > HTH,
> > > Col
> > > 
> > > -----Original Message-----
> > > From: shawn mccabe [mailto:shawn_mccabe@c...]
> > > Sent: 13 June 2002 23:29
> > > To: ASP Databases
> > > Subject: [asp_databases] popluate list box with values from 
> > a database
> > > 
> > > 
> > > How can I popluate a list box with values from a database on 
> > > a onclick 
> > > event.
> > > I can poplate the list box when the asp page loads but not on 
> > > the onclick 
> > > event why and how do I accomplish this task.
> > > 
> > > 
> > > *******
> > > 
> > > This message and any attachment are confidential and may be 
> > > privileged or otherwise protected from disclosure.  If you 
> > > are not the intended recipient, please telephone or email the 
> > > sender and delete this message and any attachment from your 
> > > system.  If you are not the intended recipient you must not 
> > > copy this message or attachment or disclose the contents to 
> > > any other person.
> > > 
> > > For further information about Clifford Chance please see our 
> > > website at http://www.cliffordchance.com or refer to any 
> > > Clifford Chance office.
> > > 
> > > 
> > 
> > 
> 

  Return to Index