ImageURL Formating

J

Jokerr

I have a problem with the Image object and ImageURL. I've looked over
some forums however I've gotten nowhere but frustrated fast. I've
verified all the data and it's correct. No special characters, just
alpha-numeric and an occasional slash(/).

I pass the following URL to my image,
"charts.aspx?labels=<data>&Data=<data>&title=<data>"

However it is formated differently,
"charts.aspx?labels=<data>&amp;Data=<data>&amp;xTitle=<data>

Here is some test code for the values
if(Request.QueryString["Labels"] == null)
Response.Write("Labels is null<br />");
else
Response.Write("Labels = " + Request.QueryString["Labels"].ToString()
+ "<br/>");
if(Request.QueryString["Data"] == null)
Response.Write("Data is null<br />");
else
Response.Write("Data = " + Request.QueryString["Data"].ToString() +
"<br/>");
if(Request.QueryString["xTitle"] == null)
Response.Write("xTitle is null<br />");
else
Response.Write("xTitle = " + Request.QueryString["xTitle"].ToString()
+ "<br/>");

Which yields the following
Labels = <data>
Data is null
xTitle is null

If I substitue Request.QueryString["data"] with
Request.QueryString["amp;data"] everything works. What am I missing?
 
C

Cowboy \(Gregory A. Beamer\)

Why are you doing this on the query string? You can dynamically add images
to an image control in code behind without having the extra page hit. The
only time this will not work is when you do not take a server trip, but your
code is embedded in the tags, so this does not appear to be the case.

<asp:Image imageUrl="notFound.gif" runat="server" id="Image1" />

CodeBehind:

string label = Request["labels"];
string data = Request["data"];
string title = Request["title"];

Image1.ImageUrl = CalculateImageUrl(label, data, title);

You then move the code to figure out which image to the CalculateImageUrl()
routine.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 
J

jokerr

I should have specified more, my bad. The charts.aspx file is used by
many different pages. charts.aspx takes in the parameters and creates
the image based on the parameters. Thus the image is different each
time and why I'm using QueryString. The main issue, IMO, is how the
image control formats the url.

In the other file (the one using the image control) I have the
following:
<asp:Image ID="imgChart" runat="server" AlternateText="Encounters
chart." />

After the user fires off the event I build the parameters and set the
imgChart.ImageURL accordingly.

charts.aspx?label=value&data=value&xTitle=value is sent to the browser
as
charts.aspx?label=value&amp;data=value&amp;xTitle=value.

charts.aspx?label=value&amp;data=value&amp;xTitle=value is sent to the
browser as
charts.aspx?label=value&amp;amp;data=value&amp;amp;xTitle=value.

Request.QueryString["data"] is always null in charts.aspx. How can I
tell the image control not to format the & sign?
 

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

Top