DataGrid and Icon

P

Pawel

Hello

I've a problem with DataGrid and Icon.
Incons are in DataGrid's cells next to the other data.

And now. When i cklick this icon i want to change
icon without reload site. How to do this?


Below part of code.


'This code open showDoc.aspx site in other other Web Browser.


lbt = e.Item.Cells(10).Controls(0)
iconFile = "edition.gif"
lbt.Text = "<a href=""showDoc.aspx?id=" & strMOZ_ID & """ >" & _
"<IMG vspace=""1"" hspace=""3"" align=""absMiddle"" height=""16""
loop=""0"" src=""images\" & iconFile & """ width=""16"" border=""0"">" &
"</a>"

Thanks.
KG
 
P

Patrick.O.Ige

Pawelku
If you want to change the icon
But change it to what? the size?
Explain
Pozdrawiam
Patrick
 
P

Pawel

Czesc

I want to change only icon without reload site.
My last query wasn't enough clearly, sorry.

I try to change icon use mouse event example:

function chanegIcon()
{
chanegIconthis.src='onsun.gif';
}

lbt.Attributes.Add("onclick", " chanegIcon( getElementById(...) ) ;"),
but i don;t know what id or name?


lbt = e.Item.Cells(10).Controls(0)
iconFile = "edition.gif"
lbt.Text = "<a href=""showDoc.aspx?id=" & strMOZ_ID & """ >" & _
"<IMG vspace=""1"" hspace=""3"" align=""absMiddle"" height=""16""
loop=""0"" src=""images\" & iconFile & """ width=""16"" border=""0"">" &
"</a>"

In brief i waht to change incon, when i click this icon.

Thanks.
KG
 
A

addup

instead of
chanegIconthis.src='onsun.gif';

try
this.src='onsun.gif';

in your javascript
 
P

Patrick.O.Ige

Pawel
Since you are using datagrid you can do it in the onItemDataBound event.
like so:-
In your datagrid template add:
<asp:Image id="Image2" runat="server" name="Image2"
ImageUrl="images/off1.gif"></asp:Image>
and code behind
Public Sub DataGrid_ItemDataBound(ByVal sender As Object, ByVal e As
DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim hyperLink As HyperLink =
CType(e.Item.FindControl("HyperLink2"), HyperLink)
Dim Image As System.Web.UI.WebControls.Image =
CType(e.Item.FindControl("Image2"), System.Web.UI.WebControls.Image)

hyperLink.Attributes.Add("onMouseOver", Image.ClientID &
".src='images/on.gif';return true;")
hyperLink.Attributes.Add("onMouseOut", Image.ClientID &
".src='images/off1.gif'; return true;")

End If
End Sub

Hope that helps
Pozdrawiam
Patrick
 

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