Databinding ImageUrl urlencodes characters

  • Thread starter mikeachamberlain
  • Start date
M

mikeachamberlain

Hi.

I have an <asp:Image> control in which I am databinding the ImageURL
attribute. The URL is another ASPX page that provides the binary
source of the image,

The problem is that ASP.NET is insisting on HTML encoding the URL
string, so the ampersands in the querystring are converted to &amps.
As a simple example of this, consider the following:

<asp:Image ID="Image1" runat="server" ImageUrl='<%#
"/Images/Download.aspx?username=mikeyc&imageID=2" %>' />

The outputted HTML is as follows:

<img id="Image1"
src="/Images/Download.aspx?username=mikeyc&amp;imageID=2" ... />

Bah! How can I stop the ampersands from being encoded?

(BTW I realise that databinding is of no help here, but I am
simplifying the example.)

Mike
 
M

Masudur

Hi.

I have an <asp:Image> control in which I am databinding the ImageURL
attribute. The URL is another ASPX page that provides the binary
source of the image,

The problem is that ASP.NET is insisting on HTML encoding the URL
string, so the ampersands in the querystring are converted to &amps.
As a simple example of this, consider the following:

<asp:Image ID="Image1" runat="server" ImageUrl='<%#
"/Images/Download.aspx?username=mikeyc&imageID=2" %>' />

The outputted HTML is as follows:

<img id="Image1"
src="/Images/Download.aspx?username=mikeyc&amp;imageID=2" ... />

Bah! How can I stop the ampersands from being encoded?

(BTW I realise that databinding is of no help here, but I am
simplifying the example.)

Mike

Hi...
I dont see any problem. with the &amp....
Because when browser submit the request for the image it convert the
&amp; to "&" please check it run the project... and right click on the
image and select property ... look for the address you will find that
things are alright...

Thanks

Masudur
kaz Software Ltd.
www.kaz.com.bd
 
M

mikeachamberlain

Masudur said:
Hi...
I dont see any problem. with the &amp....
Because when browser submit the request for the image it convert the
&amp; to "&" please check it run the project... and right click on the
image and select property ... look for the address you will find that
things are alright...

You are absolutely right - the problem lay elsewhere. Thanks for you
help.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top