Setting the image url for the image button using handler page

Posted by Gokul under Regular Expressions on 12/8/2010 | Points: 10 | Views : 3964 | Status : [Member] | Replies : 3
<asp:ImageButton ID="ImageButton1" runat="server" Width="100px" AlternateText='<%# Eval("Img_Id")%>'
Height="100px" Style="cursor: pointer" OnClientClick="viewsource('~/Handler.ashx?autoid=1')"/>


The above shown is the coding that i am using in my application for the image url to load the image in the image button.
In this in the On Client Click with the handler page i m passing the autoid =1 as a querystring. Here i am getting only one image displayed in all the rows of the grid where i kept the image button.

Can any one tell how to pass the other values from Db to the handler page to display the image in image button in grid? here the autoid is used to fetch the image from DB according to the IMage Id. can any explain.

Thanks and Regards,
GokulNath Nithy.



Responses

Posted by: Madhuk on: 12/8/2010 [Member] Starter | Points: 25

Up
0
Down
As you are passing image id 1 all the rows are displayed with same image.

<asp:ImageButton ID="ImageButton1" runat="server" Width="100px" AlternateText='<%# Eval("Img_Id")%>'
Height="100px" Style="cursor: pointer" OnClientClick="viewsource('<%# "Handler.ashx?id=" + Eval("ImgId") %>') "/>

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gokul on: 12/8/2010 [Member] Starter | Points: 25

Up
0
Down
An error is coming as the server tag is not well formed. can u help me in it?


Thanks and Regards,
GokulNath Nithy.

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhuk on: 12/8/2010 [Member] Starter | Points: 25

Up
0
Down
As you are passing the id directly there is no need for other script. just replace the below.
<asp:ImageButton ID="ImageButton2" runat="server" Width="100px" AlternateText='<%# Eval("Img_Id")%>' Height="100px" Style="cursor: pointer" ImageUrl='~/Handler1.ashx?id=+<%# Eval("Img_Id")%>+'/>

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response