popup window from datagrid using asp.net

C

csgraham74

I have a datagrid control that
pulls images into a template column using the following code


<asp:TemplateColumn HeaderText="Image">
<ItemTemplate>

<asp:image ImageUrl='<%#
FormatURL(DataBinder.Eval(Cont­ainer.DataItem,
"product_image")) %>' Width="90" Height="70" Runat=server ID="Image1"/>


</ItemTemplate>
</asp:TemplateColumn>


FormatURL - sets the path of the image.

What i want to do is to be able to click on my image in the datagrid
and for a small window to popup with the image, description and name of
my item in the window.

Im not too sure how to do this -
1. Is it possible with my current setup ?
2. What do i need to add to my image template column ???


Any asp.net examples greatly appreciated.
 
S

Scott M.

Since popup windows are only generated by the client, you will need to add
client-side code to the server-side control to make this happen.
Specifically:



I have a datagrid control that
pulls images into a template column using the following code

<A
HREF="JavaScript:popupFunction(<%#FormatURL(DataBinder.Eval(Cont­ainer.DataItem,
"product_image")) %>)">
<asp:image ImageUrl='<%#
FormatURL(DataBinder.Eval(Cont­ainer.DataItem,
"product_image")) %>' Width="90" Height="70" Runat=server ID="Image1"/>
</A>

and then in the HEAD section of the page:

<SCRIPT LANGUAGE="JavaScript">

function popupFunction(prodImage)
{
var newWin = window.open()
newWin.document.write("<IMG SRC='" + prodImage + "'>")
}

</SCRIPT>





<asp:TemplateColumn HeaderText="Image">
<ItemTemplate>

<asp:image ImageUrl='<%#
FormatURL(DataBinder.Eval(Cont­ainer.DataItem,
"product_image")) %>' Width="90" Height="70" Runat=server ID="Image1"/>


</ItemTemplate>
</asp:TemplateColumn>


FormatURL - sets the path of the image.

What i want to do is to be able to click on my image in the datagrid
and for a small window to popup with the image, description and name of
my item in the window.

Im not too sure how to do this -
1. Is it possible with my current setup ?
2. What do i need to add to my image template column ???


Any asp.net examples greatly appreciated.
 
E

Eliyahu Goldin

All you need is to set the ToolTip property of the <asp:Image..>

Eliyahu


I have a datagrid control that
pulls images into a template column using the following code


<asp:TemplateColumn HeaderText="Image">
<ItemTemplate>

<asp:image ImageUrl='<%#
FormatURL(DataBinder.Eval(Cont­ainer.DataItem,
"product_image")) %>' Width="90" Height="70" Runat=server ID="Image1"/>


</ItemTemplate>
</asp:TemplateColumn>


FormatURL - sets the path of the image.

What i want to do is to be able to click on my image in the datagrid
and for a small window to popup with the image, description and name of
my item in the window.

Im not too sure how to do this -
1. Is it possible with my current setup ?
2. What do i need to add to my image template column ???


Any asp.net examples greatly appreciated.
 
S

Scott M.

How about you simply read the OP in the first place?

"What i want to do is to be able to click on my image in the datagrid
and for a small window to popup with the image, description and name of
my item in the window."

Now, tell me how a ToolTip is going to contain an image?
 

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,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top