Ramsi said:
John,
I am finding difficulty to display an image for a Link button.
Thanks,
Ramsi
I think you missed the key point of my post, which was that you need to
put the button's image in a standard html IMG tag, not an ImageButton or
Link Button. Then, you need to add a javascript onclick event handler to
that IMG tag that calls a javascript function that will trick ASP.Net
into thinking that the user clicked on a LinkButton, even though the
user cannot actually see that LinkButton. I'll resubmit my code with
some additional changes for clarity. Hope this helps.
- John
<script lang=javascript>
// if this variable is true, imgYourButtonImage_Click() will simulate
// the user clicking on lnkYourLinkButton, even though it is not
displayed to the user
var ButtonEnabled = true;
// this is called whenever the IMG tag that contains your button
image is clicked
function imgYourButtonImage_Click()
{
if (ButtonEnabled == true)
{
// this ensures that if the user clicks your button IMG
again, a postback will not occur
ButtonEnabled = false;
// this tells ASP.Net that the user clicked on
lnkYourLinkButton
__doPostBack( 'lnkYourLinkButton', '');
}
}
</script>
<%-- This is the link button that you need to implement a server-side
event handler for.
It is hidden from the user and only "clicked" indirectly from
imgYourButtonImage_Click().
Do not set the Visible property to false or this won't work. --%>
<ASP:LinkButton ID="lnkYourLinkButton" OnClick="lnkYourLinkButton_Click"
runat=server />
<%-- This is the place where your button image is displayed to the user.
Whenever it is clicked,
imgYourButtonImage_Click() is called. The style attribute makes
cursor behave as it does
with any other button. --%>
<IMG src="BUTTON_IMAGE_PATH_HERE" onclick="imgYourButtonImage_Click();"
style="cursor:hand">