Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Images on server.

0 views
Skip to first unread message

rcoco

unread,
Mar 30, 2007, 3:47:01 AM3/30/07
to
Hi all,
I'm facing this problem I have images on my website but when I Deploye
the website on server the Images are not there I only get the X sign.
How can I go about this.
Thanks

Mark Rae

unread,
Mar 30, 2007, 4:05:24 AM3/30/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175240821.1...@d57g2000hsg.googlegroups.com...

> I'm facing this problem I have images on my website but when I Deploye
> the website on server the Images are not there I only get the X sign.
> How can I go about this.

By making sure that the images are where the rest of the app is expecting to
find them...

Why are they not there...? Have you forgotten to deploy them to the
website...? Are you using absolute addressing when you should be using
relative addressing...?


Hans Kesting

unread,
Mar 30, 2007, 5:53:27 AM3/30/07
to

And to test this, see the properties of such a failed image (or find it in
the
html-source of the page in the browser). Is the URL what you expect it to
be? Are the images really where that URL is pointing to?

Hans Kesting


rcoco

unread,
Mar 30, 2007, 9:51:54 AM3/30/07
to
On Mar 30, 12:53 pm, Hans Kesting <news.2.han...@spamgourmet.com>
wrote:
> > "rcoco" <nclau...@yahoo.ca> wrote in message

Thanks Hans,
I have managed to see it on The server But when I try getting the
website on The Client I can't see Images. what could i do?
Thanks.

Mark Rae

unread,
Mar 30, 2007, 10:02:30 AM3/30/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175262714.8...@y80g2000hsf.googlegroups.com...

> I have managed to see it on The server But when I try getting the
> website on The Client I can't see Images. what could i do?

Ah... you surely haven't hardcoded the full filespec of the image files,
have you...?

E.g. <img src="C:\Inetpub\wwwroot\MyProject\images\logo.jpg" />


rcoco

unread,
Mar 30, 2007, 11:45:02 AM3/30/07
to
On Mar 30, 5:02 pm, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> "rcoco" <nclau...@yahoo.ca> wrote in message

Thanks,
Is it any different? I'm using ImageUrl.
ImageUrl="file:///C:\Inetpub\wwwroot\MyProject\Images\logo.JPG "
Thanks

Mark Rae

unread,
Mar 30, 2007, 12:03:44 PM3/30/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175269502....@e65g2000hsc.googlegroups.com...

It's the same thing - this is never going to work...

Use relative addressing for all your images.


rcoco

unread,
Apr 2, 2007, 3:54:14 AM4/2/07
to
Hi Mark,
Could you please help me and show a simple example how to use relative
addressing?
Thank you.

rcoco

unread,
Apr 2, 2007, 4:09:00 AM4/2/07
to

Alexey Smirnov

unread,
Apr 2, 2007, 4:50:37 AM4/2/07
to

If MyProject is a name of the virtual root, you can represent it (the
root path) with a tilda (~) character.

~/Images/logo.JPG

If the web form is located in C:\Inetpub\wwwroot\MyProject\

you can use

Images/logo.JPG

Mark Rae

unread,
Apr 2, 2007, 5:32:02 AM4/2/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175500365.6...@y66g2000hsf.googlegroups.com...

> Could you please help me and show a simple example how to use relative
> addressing?

http://www.google.co.uk/search?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2006-28,GGLG:en&q=HTML+%22relative+address%22


rcoco

unread,
Apr 2, 2007, 5:58:56 AM4/2/07
to
thanks,
I have just tried it but it ain't working this is how I've just tried
it: ImageUrl="file:///C:\Inetpub\wwwroot\Images\logo.JPG".
Thanks.

Mark Rae

unread,
Apr 2, 2007, 6:26:33 AM4/2/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175507936....@y66g2000hsf.googlegroups.com...

Rocco,

> I have just tried it but it ain't working this is how I've just tried
> it: ImageUrl="file:///C:\Inetpub\wwwroot\Images\logo.JPG".

You cannot hard-code the absolute path like this!!!

Not sure why you seem to be finding this so difficult to understand...

Imagine your site has the following structure (FORGET TOTALLY ABOUT
C:\Inetpub\wwwroot !!!)

<root>
\bin
\Properties
\References
\Folder1
File1.aspx
File2.aspx
\Folder2
File3.aspx
File4.aspx
\images
logo.jpg
\master
default.master
default.aspx
Global.asax
web.config

You are editing \Folder1\File1.aspx and want to include a link to your
logo - do this:

ImageUrl="../images/logo.jpg"

or

ImageUrl="~/images/logo.jpg"


rcoco

unread,
Apr 2, 2007, 8:04:34 AM4/2/07
to
Thanks Ray,
When I did this:ImageUrl="../Images/logo.JPG", Even on serverside
cannot see the image.
Thanks.

Alexey Smirnov

unread,
Apr 2, 2007, 8:17:26 AM4/2/07
to

and what about TILDA?

rcoco

unread,
Apr 2, 2007, 8:31:17 AM4/2/07
to
Even tilda does not show any Image.
Thanks

Mark Rae

unread,
Apr 2, 2007, 9:04:48 AM4/2/07
to
"Alexey Smirnov" <alexey....@gmail.com> wrote in message
news:1175516246.1...@n76g2000hsh.googlegroups.com...

http://en.wikipedia.org/wiki/Tilde


Mark Rae

unread,
Apr 2, 2007, 9:04:39 AM4/2/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175517077.5...@o5g2000hsb.googlegroups.com...

> Even tilda does not show any Image.

Do a View Source and look at the URL that ASP.NET has created - what does it
say...?


rcoco

unread,
Apr 2, 2007, 10:11:48 AM4/2/07
to
On Apr 2, 4:04 pm, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> "rcoco" <nclau...@yahoo.ca> wrote in message


It says: <img id="Logo2" src="../Images/logo.JPG".
Thanks.

Mark Rae

unread,
Apr 2, 2007, 10:19:50 AM4/2/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175523108....@o5g2000hsb.googlegroups.com...

Cool! Now we're getting somewhere - you're finally using relative
addressing - hurrah!

So, is the above source actually correct relative to the folder that the
ASPX is in...?


rcoco

unread,
Apr 2, 2007, 10:42:23 AM4/2/07
to
On Apr 2, 5:19 pm, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> "rcoco" <nclau...@yahoo.ca> wrote in message
>
> news:1175523108....@o5g2000hsb.googlegroups.com...
>
> > On Apr 2, 4:04 pm, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> >> "rcoco" <nclau...@yahoo.ca> wrote in message
>
> >>news:1175517077.5...@o5g2000hsb.googlegroups.com...
>
> >> > Even tilda does not show any Image.
>
> >> Do a View Source and look at the URL that ASP.NET has created - what does
> >> it
> >> say...?
>
> > It says: <img id="Logo2" src="../Images/logo.JPG".
>
> Cool! Now we're getting somewhere - you're finally using relative
> addressing - hurrah!
>
> So, is the above source actually correct relative to the folder that the
> ASPX is in...?

Yes it is.

rcoco

unread,
Apr 3, 2007, 7:39:02 AM4/3/07
to
> Yes it is.- Hide quoted text -
>
> - Show quoted text -

Hi,
I was wondering does it matter where I place the folder with the
Images could it be the problem?
Thanks.

Mark Rae

unread,
Apr 3, 2007, 8:35:05 AM4/3/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175600342.7...@b75g2000hsg.googlegroups.com...

> I was wondering does it matter where I place the folder with the
> Images

Of course it does!!!


rcoco

unread,
Apr 3, 2007, 9:13:34 AM4/3/07
to
On Apr 3, 3:35 pm, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> "rcoco" <nclau...@yahoo.ca> wrote in message

They are next to the Bin folder hope I'm not doing a mistake!
Thanks

Mark Rae

unread,
Apr 3, 2007, 9:23:34 AM4/3/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175606014.8...@d57g2000hsg.googlegroups.com...

Oh dear... The important thing here is the depth of the folder in relation
to the root.

Once again...

Imagine your site has the following structure (FORGET TOTALLY ABOUT
C:\Inetpub\wwwroot !!!)

<root>
\bin
\Properties
\References
\Folder1
File1.aspx
File2.aspx
\Folder2
File3.aspx
File4.aspx

\Folder3
File5.aspx


\images
logo.jpg
\master
default.master
default.aspx
Global.asax
web.config

You are editing \Folder1\File1.aspx and want to include a link to your
logo - do this: ImageUrl="../images/logo.jpg"

However, that wouldn't work for File5.aspx because it is at a different
depth relative to the root. For File5.aspx, you'd need to do:
ImageUrl="../../images/logo.jpg"

Alexey Smirnov

unread,
Apr 3, 2007, 9:35:24 AM4/3/07
to
On Apr 3, 3:23 pm, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> You are editing \Folder1\File1.aspx and want to include a link to your
> logo - do this: ImageUrl="../images/logo.jpg"
>
> However, that wouldn't work for File5.aspx because it is at a different
> depth relative to the root. For File5.aspx, you'd need to do:
> ImageUrl="../../images/logo.jpg"

Parent paths are disabled by default in IIS 6.0 and can be disabled on
IIS 5 as well.

Why don't you use

ImageUrl="/images/logo.jpg"

That path will always work, with no depends where the aspx is located.

Alexey Smirnov

unread,
Apr 3, 2007, 9:37:04 AM4/3/07
to
On Apr 2, 3:04 pm, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message

All right. Good to know

rcoco

unread,
Apr 4, 2007, 7:45:48 AM4/4/07
to
On localhost, the code: ImageUrl="/images/logo.jpg" works but when
deployed on server it doesnot work? Why is it so?
Thanks.

Alexey Smirnov

unread,
Apr 4, 2007, 8:23:27 AM4/4/07
to

On the server you should have the same configuration as on the
localhost. Namely,

1) the aspx page is in the root directory
2) the root directory has /images
3) logo.JPG is in the /images

rcoco

unread,
Apr 4, 2007, 9:50:27 AM4/4/07
to
Thanks alot,
I have just realised my stupid mistake, I wasn't deploying the Image
after deploying the image i had to only add this code in html:
ImageUrl="logo.JPG" and now it's working well.
Thanks again.

Mark Rae

unread,
Apr 4, 2007, 10:04:43 AM4/4/07
to
"rcoco" <ncla...@yahoo.ca> wrote in message
news:1175694627.8...@l77g2000hsb.googlegroups.com...

> I have just realised my stupid mistake, I wasn't deploying the Image

That was the very first thing I asked you in my first reply to your original
post back on 30th March...


rcoco

unread,
Apr 5, 2007, 1:41:07 AM4/5/07
to
Yes I have realised that's true that's why it becomes more stupid of
me not to have realised that yet I had the answer from you at the
begining. Sorry for that and I really Appriciate all the help.
Thanks alot

rcoco

unread,
Apr 5, 2007, 3:36:11 AM4/5/07
to
Here again I'm in trouble. I have this datagrid column that is
Supposed to hold both Character and Image. I set RadioButtonlist that
has two radiobutton. One good mood the other one bad mood. In the same
column are two images one imggm the other imgbm. When radiobutton good
mood is selected I want image imggm to be selected automatically. I'm
using this code.

System.Web.UI.WebControls.RadioButtonList st5=new
System.Web.UI.WebControls.RadioButtonList();
st5=(System.Web.UI.WebControls.RadioButtonList)e.Item.Cells[1].FindControl("rblmood");
System.Web.UI.WebControls.Image imgDaily=new
System.Web.UI.WebControls.Image();
imgDaily=(System.Web.UI.WebControls.Image)e.Item.Cells[1].FindControl("imgbm");
myCommand.Parameters.Add(new SqlParameter("@MoodToday",SqlDbType.Char,
45));
if(e.Item.Cells[1].Equals("Bad Mood"))
{
imgDaily.ImageUrl = "imgbm";
}
else
{
imgDaily.ImageUrl = "imggm";
}
myCommand.Parameters["@MoodToday"].Value=st5.SelectedValue;
My problem is that only goog mood appears but the image imggm does not
does not appear how should I do it.
Thanks

Alexey Smirnov

unread,
Apr 5, 2007, 4:51:34 AM4/5/07
to
On Apr 5, 9:36 am, "rcoco" <nclau...@yahoo.ca> wrote:
> Here again I'm in trouble. I have this datagrid column that is
> Supposed to hold both Character and Image. I set RadioButtonlist that
> has two radiobutton. One good mood the other one bad mood. In the same
> column are two images one imggm the other imgbm. When radiobutton good
> mood is selected I want image imggm to be selected automatically. I'm
> using this code.
>
> System.Web.UI.WebControls.RadioButtonList st5=new
> System.Web.UI.WebControls.RadioButtonList();
> st5=(System.Web.UI.WebControls.RadioButtonList)e.Item.Cells[1].FindControl(­"rblmood");
> System.Web.UI.WebControls.Image imgDaily=new
> System.Web.UI.WebControls.Image();
> imgDaily=(System.Web.UI.WebControls.Image)e.Item.Cells[1].FindControl("imgb­m");

> myCommand.Parameters.Add(new SqlParameter("@MoodToday",SqlDbType.Char,
> 45));
> if(e.Item.Cells[1].Equals("Bad Mood"))
> {
> imgDaily.ImageUrl = "imgbm";}
>
> else
> {
> imgDaily.ImageUrl = "imggm";}
>
> myCommand.Parameters["@MoodToday"].Value=st5.SelectedValue;
> My problem is that only goog mood appears but the image imggm does not
> does not appear how should I do it.
> Thanks

>From the code above you cannot see if e.Item.Cells[1] equals the "Bad
Mood" or not. I'm also confused about

e.Item.Cells[1].FindControl("imgb­m");

It used the same cell of the grid. If cell[1] contains a control named
"imgb­m", it cannot be equal to the "Bad Mood"

rcoco

unread,
Apr 5, 2007, 6:02:08 AM4/5/07
to
Imgbm is a sad img is supposed to equal Bad Mood. And these are two
different images. it's supposed to be small image followed by the word
bad or good mood now e.Item.Cells[1].FindControl("imgb­m"); I'm not
sure about it at all. But hope you've managed to get what I want to
do? If you could help me Please.
Thanks

Alexey Smirnov

unread,
Apr 5, 2007, 8:43:00 AM4/5/07
to

"Imgbm" cannot be a name of an image and you cannot use it as a value
for the ImageUrl property.

e.Item.Cells[1] cannot be equals to "Bad Mood". If "Bad Mood" is a
value of a radiobutton, then you should compare the value of the
radiobutton

if(st5.SelectedValue == "Bad Mood") {
...
} else {
...
}

Start the application in Debug Mode and check the values.

rcoco

unread,
Apr 5, 2007, 10:37:11 AM4/5/07
to
Hi,
have just tryed this but it seems not to work? where is it wrong?
if(st5.SelectedValue=="Bad Mood")
{
st5.SelectedValue="Images/sad.gif";
}
else if(st5.SelectedValue=="Good Mood")
{
st5.SelectedValue="Images/laughing.gif";
}
And this is the error I'm getting:
Specified argument was out of the range of valid values. Parameter
name: Images/laughing.gif.
Thanks

Alexey Smirnov

unread,
Apr 5, 2007, 4:10:57 PM4/5/07
to

st5 is your RadioButtonList

st5=(System.Web.UI.WebControls.RadioButtonList)e.Item.Cells[1].FindControl(­"rblmood");

so, what do you want to get using

st5.SelectedValue="Images/laughing.gif";

?

rcoco

unread,
Apr 10, 2007, 12:57:31 AM4/10/07
to

Sorry I've been away for some time. Yes st5 is my RadioButtonList. I
want the image laughing to come along when good mood is selected.
that's: st5.SelectedValue="Images/laughing.gif";
Thanks.

Alexey Smirnov

unread,
Apr 10, 2007, 3:12:09 AM4/10/07
to
> Thanks.- Hide quoted text -

>
> - Show quoted text -

1) SelectedValue is a read-only property and you cannot assign a value
using st5.SelectedValue=...

2) st5 is a RadioButtonList and it cannot be equal to the "Images/
laughing.gif"

rcoco

unread,
Apr 10, 2007, 3:28:40 AM4/10/07
to
On Apr 10, 10:12 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
> laughing.gif"- Hide quoted text -

>
> - Show quoted text -

Is that the reason I'm getting this error:


Specified argument was out of the range of valid values. Parameter

name: Images/laughing.gif ?
Thanks

Alexey Smirnov

unread,
Apr 10, 2007, 3:54:28 AM4/10/07
to
> Thanks- Hide quoted text -

>
> - Show quoted text -

Wait, I think I made a mistake telling that it's a read-only:

MSDN: "Gets the value of the selected item in the list control, or
selects the item in the list control that contains the specified
value."
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

Sorry.

The error message "Specified argument was out of the range of valid
values. Parameter name: Images/laughing.gif" means that there is no
such value "Images/laughing.gif".

Mark Rae

unread,
Apr 10, 2007, 4:01:23 AM4/10/07
to
"Alexey Smirnov" <alexey....@gmail.com> wrote in message
news:1176189129.1...@l77g2000hsb.googlegroups.com...

> 1) SelectedValue is a read-only property

No it isn't...


Alexey Smirnov

unread,
Apr 10, 2007, 4:14:33 AM4/10/07
to
On Apr 10, 10:01 am, "Mark Rae" <m...@markNOSPAMrae.com> wrote:
> "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message

>
> news:1176189129.1...@l77g2000hsb.googlegroups.com...
>
> > 1) SelectedValue is a read-only property
>
> No it isn't...

I had already replied on this

Mark Rae

unread,
Apr 10, 2007, 4:21:28 AM4/10/07
to
"Alexey Smirnov" <alexey....@gmail.com> wrote in message
news:1176192873....@w1g2000hsg.googlegroups.com...

Sorry - your reply hadn't arrived when I posted...


rcoco

unread,
Apr 10, 2007, 4:33:41 AM4/10/07
to
On Apr 10, 11:14 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:

How can I make it work? Please help me.
thanks

Alexey Smirnov

unread,
Apr 10, 2007, 5:07:09 AM4/10/07
to

Mark, no problem, actually I don't know why I thought it's a read-only
property. Maybe I had never used that before.

Rcoco,

You should understand conceptually what you are doing, rather than
following copy-and-paste code blindly. Your program is working as you
designed it, and not as you might think it should work.

You have to understand what the "out of the range of valid values"
means. This means that st5 (a RadioButtonList) has no value named
"Images/laughing.gif". I cannot answer, how you can make it working,
because I don't know how it should work. You used the following code
before:

imgDaily.ImageUrl = "imgbm"

Now, you are using

st5.SelectedValue = "..."

Why did you change this and what is the logic behind?

I thought, you wanted to change an image. Using st5.SelectedValue you
will change selection (a point) of the radio button.

If you definitely need to change the selected item in the
RadioButtonList you should know what values it has. Look in your code
where you bind the values (dataset, whatever) to this control.

Alexey Smirnov

unread,
Apr 10, 2007, 5:13:24 AM4/10/07
to
On Apr 10, 11:07 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:
> where you bind the values (dataset, whatever) to this control.- Hide quoted text -

>
> - Show quoted text -

P.S.

If you don't get what I mean, once again post the complete source code
of your radio button list which is not working as expected (aspx part
and code-behind) and explain how it should work step by step.

rcoco

unread,
Apr 10, 2007, 5:38:38 AM4/10/07
to
This is how the code looks like:

private void Page_Load(object sender, System.EventArgs e)
{
if (! IsPostBack)
{
Fill();
Bind();
}
}
System.Web.UI.WebControls.RadioButtonList st5=new
System.Web.UI.WebControls.RadioButtonList();


st5=(System.Web.UI.WebControls.RadioButtonList)e.Item.Cells[1].FindControl("rblmood");

SqlCommand myCommand=new SqlCommand();
myCommand.Connection=con;
myCommand.CommandText="insert into DashBoard (MoodToday) values
(@MoodToday)";
myCommand.Parameters.Add(new
SqlParameter("@MoodToday",SqlDbType.Text));
myCommand.Parameters["@MoodToday"].Value=st5.SelectedValue;
if(st5.SelectedValue=="Bad Mood")
{
st5.SelectedValue="images/sad.gif";


}
else if(st5.SelectedValue=="Good Mood")
{

st5.SelectedValue="images/laughing.gif";
}
Fill();
InsertEmpty();
Bind();
This is the HTML part
<ItemTemplate>
<asp:Label id=Label2 runat="server" Width="104px" text='<%#
DataBinder.Eval(Container,"DataItem.MoodToday")%>'>Label</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList id="rblmood" runat="server" Width="104px">
<asp:ListItem Value="Good Mood">Good Mood</asp:ListItem>
<asp:ListItem Value="Bad Mood">Bad Mood</asp:ListItem>
</asp:RadioButtonList>
<asp:Image id="imggm" runat="server" ImageUrl="../Images/laughing.gif"
ImageAlign="Right"></asp:Image>
<asp:Image id="imgbm" runat="server" ImageUrl="../Images/sad.gif"
ImageAlign="Right"></asp:Image>
</EditItemTemplate>
Thanks

rcoco

unread,
Apr 10, 2007, 5:45:25 AM4/10/07
to
This how it is supposed to work.
When a user selects RadioButton GoodMood the image imggm(laughing.gif)
should be selected as well.
and if BadMood is selected Image imgbm it should be imgbm(sad.gif).
Thanks.

Alexey Smirnov

unread,
Apr 10, 2007, 5:53:17 PM4/10/07
to

What do you mean by "the image should be selected"?

Assuming the code is working properly, except a "selection" of the
image, you should change the if..else block

Image imggm = (Image)e.Item.Cells[1].FindControl("imggm");
Image imgbm = (Image)e.Item.Cells[1].FindControl("imgbm");

if (st5.SelectedValue == "Bad Mood")
{
imgbm.BorderWidth = Unit.Pixel(2);
} else {
imggm.BorderWidth = Unit.Pixel(2);
}

This code put a border around the first image if st5.SelectedValue !=
"Bad Mood", otherwise, the second image will be bordered. This is how
I understand your "selection".

Hope, it helps.

rcoco

unread,
Apr 11, 2007, 1:23:17 AM4/11/07
to
Hi,
Lets say this is any of the image: ))(( .
What I'm trying is to get the out put look like: ))(( Good Mood
after inserting data In a datagrid cell for right now after inserting
data I only get Good Mood. with out the Image.
As You see in the html code The Image and RadioButtonList are in
EditItemTemplate:

<EditItemTemplate>
<asp:RadioButtonList id="rblmood" runat="server" Width="112px">


<asp:ListItem Value="Good Mood">Good Mood</asp:ListItem>
<asp:ListItem Value="Bad Mood">Bad Mood</asp:ListItem>
</asp:RadioButtonList>
<asp:Image id="imggm" runat="server" ImageUrl="../Images/

laughing.gif"></asp:Image>
<asp:Image id="imgbm" runat="server" ImageUrl="../Images/sad.gif"></
asp:Image>
</EditItemTemplate>

Thanks

Alexey Smirnov

unread,
Apr 11, 2007, 2:44:41 AM4/11/07
to

I don't get your reply.

What problem do you have? An image sad.gif is not shown? If yes, when
the problem occurs, when page is initially loaded or after you changed
a selection of the RadioButtonList?

rcoco

unread,
Apr 11, 2007, 3:56:11 AM4/11/07
to
> a selection of the RadioButtonList?- Hide quoted text -

>
> - Show quoted text -

It's supposed to work like this When on selection of RadioButton from
RadioButtonList and inserts data that is when Image should be visible
in datagrid column. For example if Bad Mood is selected and inserted
into database, image sad.gif should be visible in datagrid column:
))(( Bad Mood (consider ))(( to be image sad.gif).
This should be after one has inserted data.
Thanks
Thanks.

rcoco

unread,
Apr 11, 2007, 4:53:28 AM4/11/07
to
> Thanks.- Hide quoted text -

>
> - Show quoted text -

Alexey,
What if I Change the images from EditItemTemplate to ItemTemplate
wouldn't it be better? As in I make the images invisible and When I
edit my data in datagrid one of the images becomes visible can tha
work?
Thanks

Alexey Smirnov

unread,
Apr 11, 2007, 4:55:26 AM4/11/07
to
> Thanks.- Hide quoted text -

>
> - Show quoted text -

But then I think it has nothing to do with the EditItemTemplate

If I understand you correct, you have to change

<EditItemTemplate>
<asp:RadioButtonList id="rblmood" runat="server" Width="104px">


<asp:ListItem Value="Good Mood">Good Mood</asp:ListItem>
<asp:ListItem Value="Bad Mood">Bad Mood</asp:ListItem>
</asp:RadioButtonList>
<asp:Image id="imggm" runat="server" ImageUrl="../Images/
laughing.gif"

ImageAlign="Right"></asp:Image>


<asp:Image id="imgbm" runat="server" ImageUrl="../Images/sad.gif"

ImageAlign="Right"></asp:Image>
</EditItemTemplate>

to:

<EditItemTemplate>
<asp:RadioButtonList id="rblmood" runat="server" Width="104px">


<asp:ListItem Value="Good Mood">Good Mood</asp:ListItem>
<asp:ListItem Value="Bad Mood">Bad Mood</asp:ListItem>
</asp:RadioButtonList>

</EditItemTemplate>

and delete the following part

if(st5.SelectedValue=="Bad Mood")
{
st5.SelectedValue="images/sad.gif";
}
else if(st5.SelectedValue=="Good Mood")
{
st5.SelectedValue="images/laughing.gif";
}

The EditItemTemplate used to edit a current record in the datagrid.

That is:

1) you bind your grid to the database
2) you show EditItemTemplate with your radio buttons
3) you post the web form back to the server
4) you find a selected value of the radio button

<-- I guess, you are this step

5) you save the selected value to a database
6) you bind your grid to the database again

So, you should update the database (step #5) and repeat step #1 which
is the same to step #6

How to with a DataGrid
http://www.google.com/search?hl=en&q=datagrid+tutorial+asp.net

rcoco

unread,
Apr 11, 2007, 6:05:56 AM4/11/07
to
On Apr 11, 11:55 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
> How to with a DataGridhttp://www.google.com/search?hl=en&q=datagrid+tutorial+asp.net- Hide quoted text -

>
> - Show quoted text -

But after updating the datagrid how can I make one I mage visible?
Thnks

Alexey Smirnov

unread,
Apr 11, 2007, 6:26:30 AM4/11/07
to
On Apr 11, 12:05 pm, "rcoco" <nclau...@yahoo.ca> wrote:
>
> But after updating the datagrid how can I make one I mage visible?
> Thnks- Hide quoted text -
>

You are right, I forgot to mention.

You can have an additional column in your datagrid, where you will
show your "mood".

I'm not sure what exactly you kept in the database as a "mood" value:
a string, or numeric value?

If you kept a string in the database ("sad", or "laughing")

the code will be

<asp:TemplateColumn>
<ItemTemplate>
<asp:Image Runat="server" ID="Image1" ImageUrl='<%# "/Images/" +
DataBinder.Eval(Container.DataItem, "Mood") + ".gif" %>'/>
</ItemTemplate>
</asp:TemplateColumn>

where Mood is a name of your datasource field

If you save your mood as a numeric value (e.g. "0" - for sad, "1" -
for "laughing")

<asp:TemplateColumn>
<ItemTemplate>
<asp:Image Runat="server" ID="Image1" ImageUrl='<%# "/Images/" +
((int)DataBinder.Eval(Container.DataItem, "Mood") == 0 ? "sad" :
"laughing") + ".gif" %>'/>
</ItemTemplate>
</asp:TemplateColumn>

rcoco

unread,
Apr 11, 2007, 7:32:49 AM4/11/07
to

Seems not working I'm i getting it right?
<ItemTemplate>
<asp:Label id=Label2 runat="server" Width="97px" text='<%#


DataBinder.Eval(Container,"DataItem.MoodToday")%>'>Label</asp:Label>

<asp:Image id=imgbm runat="server" ImageUrl='<%# "/Images/"
+DataBinder.Eval(Container.DataItem, "MoodToday") + "../Images/
sad.gif"%>' Visible="False">
</asp:Image>
<asp:Image id=imggm runat="server" ImageUrl='<%# "/Images/"
+DataBinder.Eval(Container.DataItem, "MoodToday") + "../images/
laughing.gif"%>' Visible="False">
</asp:Image>
</ItemTemplate>
Thanks

Alexey Smirnov

unread,
Apr 11, 2007, 8:03:15 AM4/11/07
to
> Thanks- Hide quoted text -

>
> - Show quoted text -

ImageUrl='<%# "/Images/" +DataBinder.Eval(Container.DataItem,
"MoodToday") + "../Images/sad.gif"%>'

Using the code above, what URL are you expecting to get in the output?

rcoco

unread,
Apr 11, 2007, 8:10:37 AM4/11/07
to
> Using the code above, what URL are you expecting to get in the output?- Hide quoted text -

>
> - Show quoted text -

I want to get Sad.gif when its Bad mood that was selected.
thanks

Alexey Smirnov

unread,
Apr 11, 2007, 9:00:38 AM4/11/07
to
On Apr 11, 2:10 pm, "rcoco" <nclau...@yahoo.ca> wrote:
>
> > ImageUrl='<%# "/Images/" +DataBinder.Eval(Container.DataItem,
> > "MoodToday") + "../Images/sad.gif"%>'
>
> > Using the code above, what URL are you expecting to get in the output?- Hide quoted text -
>
>
> I want to get Sad.gif when its Bad mood that was selected.
> thanks- Hide quoted text -
>

I will rephrase the question:

"/Images/" + {something} + "../Images/sad.gif" = ?

rcoco

unread,
Apr 11, 2007, 9:31:48 AM4/11/07
to

that's for getting the ImageUrl .

rcoco

unread,
Apr 11, 2007, 10:18:01 AM4/11/07
to

Alexey,
You gave this example and I've just nrealised that actually I did not
understand it:


<asp:TemplateColumn>
<ItemTemplate>
<asp:Image Runat="server" ID="Image1" ImageUrl='<%# "/Images/" +
DataBinder.Eval(Container.DataItem, "Mood") + ".gif" %>'/>
</ItemTemplate>
</asp:TemplateColumn>

Could you try to explain to me please?

Alexey Smirnov

unread,
Apr 11, 2007, 10:45:10 AM4/11/07
to
> Could you try to explain to me please?- Hide quoted text -

>
> - Show quoted text -

I understand that you don't understand. But you have to understand
that "A"+"B" = "AB".

The goal is to show an image, which is located somewhere on a server.
I don't know exactly what url does your image, but I suppose it is
something like this

/Images/laughing.gif
/Images/sad.gif

To check if I'm right (and the url is right) type that url in the
address bar of your browser.

For example:

http://servername/Images/laughing.gif
http://localhost/Images/laughing.gif (if you do it locally)

You should see an image.

If you don't see it - the url is wrong, and you have to find the right
url.

A: What is the right url?

Now, when we know an url, we come to another question: what value do
you have in the database.

MoodToday is.... a number, a string.... ? what?

Assuming it is a string.
Assuming it is either "sad", or "laughing".

B: What is the value of MoodToday?

Please answer these 2 questions for me and we could finally check if
"A"+"B" = "AB"

rcoco

unread,
Apr 11, 2007, 11:16:06 AM4/11/07
to
> http://servername/Images/laughing.gifhttp://localhost/Images/laughing.gif(if you do it locally)

>
> You should see an image.
>
> If you don't see it - the url is wrong, and you have to find the right
> url.
>
> A: What is the right url?
>
> Now, when we know an url, we come to another question: what value do
> you have in the database.
>
> MoodToday is.... a number, a string.... ? what?
>
> Assuming it is a string.
> Assuming it is either "sad", or "laughing".
>
> B: What is the value of MoodToday?
>
> Please answer these 2 questions for me and we could finally check if
> "A"+"B" = "AB"- Hide quoted text -

>
> - Show quoted text -

The right URL is http://localhost/Images/laughing.gif,
Mood today is a string, the value of Mood Today is text 16
Thanks

rcoco

unread,
Apr 11, 2007, 11:21:37 AM4/11/07
to
> >http://servername/Images/laughing.gifhttp://localhost/Images/laughing...you do it locally)

>
> > You should see an image.
>
> > If you don't see it - the url is wrong, and you have to find the right
> > url.
>
> > A: What is the right url?
>
> > Now, when we know an url, we come to another question: what value do
> > you have in the database.
>
> > MoodToday is.... a number, a string.... ? what?
>
> > Assuming it is a string.
> > Assuming it is either "sad", or "laughing".
>
> > B: What is the value of MoodToday?
>
> > Please answer these 2 questions for me and we could finally check if
> > "A"+"B" = "AB"- Hide quoted text -
>
> > - Show quoted text -
>
> The right URL ishttp://localhost/Images/laughing.gif,

> Mood today is a string, the value of Mood Today is text 16
> Thanks- Hide quoted text -

>
> - Show quoted text -

I forgot the value that are in MoodToday are Good Mood & Bad Mood.
Thanks

Larry Bud

unread,
Apr 11, 2007, 11:57:54 AM4/11/07
to
On Apr 2, 8:04 am, "rcoco" <nclau...@yahoo.ca> wrote:
> Thanks Ray,
> When I did this:ImageUrl="../Images/logo.JPG", Even on serverside
> cannot see the image.
> Thanks.

No offense, but how in the world are you a .NET developer yet don't
understand such a simple concept as relative address of an HTML image?

Mark Rae

unread,
Apr 11, 2007, 1:37:39 PM4/11/07
to
"Larry Bud" <larryb...@yahoo.com> wrote in message
news:1176307074....@l77g2000hsb.googlegroups.com...

:-)

I am staggered at Alexey's patience with this guy - I gave up days ago...

I'd hate to be his boss!


Alexey Smirnov

unread,
Apr 11, 2007, 2:16:17 PM4/11/07
to
> > >http://servername/Images/laughing.gifhttp://localhost/Images/laughing...do it locally)

>
> > > You should see an image.
>
> > > If you don't see it - the url is wrong, and you have to find the right
> > > url.
>
> > > A: What is the right url?
>
> > > Now, when we know an url, we come to another question: what value do
> > > you have in the database.
>
> > > MoodToday is.... a number, a string.... ? what?
>
> > > Assuming it is a string.
> > > Assuming it is either "sad", or "laughing".
>
> > > B: What is the value of MoodToday?
>
> > > Please answer these 2 questions for me and we could finally check if
> > > "A"+"B" = "AB"- Hide quoted text -
>
> > > - Show quoted text -
>
> > The right URL ishttp://localhost/Images/laughing.gif,
> > Mood today is a string, the value of Mood Today is text 16
> > Thanks- Hide quoted text -
>
> > - Show quoted text -
>
> I forgot the value that are in MoodToday are Good Mood & Bad Mood.
> Thanks- Hide quoted text -
>
> - Show quoted text -

Okay, going back to the code I sent you some time ago:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Image Runat="server" ID="Image1" ImageUrl='<%# "/Images/" +

((string)DataBinder.Eval(Container.DataItem, "MoodToday") == "Bad
Mood" ? "sad" :
"laughing") + ".gif" %>'/>
</ItemTemplate>
</asp:TemplateColumn>

The code above would show one of two images:

MoodToday = "Bad Mood" ---> /images/sad.gif
otherwise ---> /images/laughing.gif

If you will have any problem with that Image Control you should debug
your code.

It could be done, e.g. like the following example:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Image Runat="server" ID="Image1" ImageUrl='<%# "/Images/" +

((string)DataBinder.Eval(Container.DataItem, "MoodToday") == "Bad
Mood" ? "sad" :
"laughing") + ".gif" %>'/>

Current Mood in the database is: <%#
DataBinder.Eval(Container.DataItem, "MoodToday") %>

Image URL is: <%# "/Images/" +
((string)DataBinder.Eval(Container.DataItem, "MoodToday") == "Bad
Mood" ? "sad" :


"laughing") + ".gif" %>

</ItemTemplate>
</asp:TemplateColumn>

I hope I didn't make any mistake and my code will work for you and we
finally close the issue with images :-)

Alexey Smirnov

unread,
Apr 11, 2007, 2:23:57 PM4/11/07
to
On Apr 11, 7:37 pm, "Mark Rae" <m...@markNOSPAMrae.net> wrote:
> "Larry Bud" <larrybud2...@yahoo.com> wrote in message

The author deserve admiration for his persistence and stubbornness :-)

Mark Rae

unread,
Apr 11, 2007, 2:31:33 PM4/11/07
to
"Alexey Smirnov" <alexey....@gmail.com> wrote in message
news:1176315837....@q75g2000hsh.googlegroups.com...

> The author deserve admiration for his persistence and stubbornness :-)

That's one way of looking at it...!


rcoco

unread,
Apr 12, 2007, 5:20:55 AM4/12/07
to
Thanks Alexey for the help and for the patience.
The code

Image URL is: <%# "/Images/" +
((string)DataBinder.Eval(Container.DataItem, "MoodToday") == "Bad
Mood" ? "sad" : "laughing") + ".gif" %>

I get the error Specified cast is not valid at run time.

And when I changed the code to
<asp:Image id=Image1 runat="server" ImageUrl='<
%#DataBinder.Eval(Container.DataItem,"MoodToday")=="Bad
Mood"?"sad":"laughing" )+".gif"%>' Visible="True">
</asp:Image>

Only the Image laughing .gif appears whether Good Mood or Bad Mood is
selected.
Why is it so?


Alexey Smirnov

unread,
Apr 12, 2007, 10:33:36 AM4/12/07
to

Have you tried to debug it?

Put this line as I already told you

Current Mood in the database is: ***<%#
DataBinder.Eval(Container.DataItem, "MoodToday") %>***

If you believe that a "Bad Mood" is selected (it has to be saved(!))
then you will see

***Bad Mood***

Otherwise you will see

***Good Mood***
***abracadabra***
******
and so on

rcoco

unread,
Apr 13, 2007, 2:01:52 AM4/13/07
to
> and so on- Hide quoted text -

>
> - Show quoted text -
Thanks Alexey,
It has worked properly. I had to select Bad Mood By default like you
had advised me.
I Really Want to thank you so so much it has worked so well. Thank you
especially for yo patience it's unusial.
Thanks again and to the rest who helped me in giving me a clou.

rcoco

unread,
Apr 13, 2007, 3:30:33 AM4/13/07
to
> Thanks again and to the rest who helped me in giving me a clou.- Hide quoted text -

>
> - Show quoted text -

Sorry again Every thing was going on well but all of a sudden I got a
wired reaction:
Why is it that when I insert data I fast get an error :
Specified cast is not valid.
But When I run the site for the second time I find the data was saved
the right image was selected! Actually I can say every thing works
well apart that when ever I attempt to insert data this error appears:
Specified cast is not valid. on line:
<asp:Image id=Image1 runat="server" ImageUrl='<%#"/Images/"+
((string)DataBinder.Eval(Container.DataItem,"MoodToday")=="Bad
Mood"?"sad":"laughing") +".gif"%>' ImageAlign="Middle">.
Thanks


rcoco

unread,
Apr 13, 2007, 9:52:59 AM4/13/07
to
> Thanks- Hide quoted text -

>
> - Show quoted text -

Actually the error reads: System.InvalidCastException: Specified cast
is not valid.

and the stack Trace

[InvalidCastException: Specified cast is not valid.]
ASP.DashBoard_aspx.__DataBind__control16(Object sender, EventArgs
e) in c:\inetpub\wwwroot\Dash_Board\DashBoard.aspx:46
System.Web.UI.Control.OnDataBinding(EventArgs e)
System.Web.UI.Control.DataBind()
System.Web.UI.Control.DataBind()
System.Web.UI.Control.DataBind()
System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex,
Int32 dataSourceIndex, ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollection rows,
PagedDataSource pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
Dash_Board.DashBoard.Bind() in c:\inetpub\wwwroot\dash_board
\dashboard.aspx.cs:109
Dash_Board.DashBoard.dgis_ItemCommand(Object source,
DataGridCommandEventArgs e) in c:\inetpub\wwwroot\dash_board
\dashboard.aspx.cs:176

System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs
e)
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source,
EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args)
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source,
EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args)
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()

Help me please.
Thanks

0 new messages