doglin
doglin

Reputation: 1741

design a button with a custom image? is it possible?

Is it possible to put a button on my user control .ascx (the web part in this case), and have a customized image with that? What I am trying to do is have a "print" button to print the page.

However, I don't want to use the default asp button, I want to have a the special "print" icon associated with it. So, can I do this and still use <asp:button>?

Or is it just better to make that "print" icon a link, and do OnClick on the link event?

Upvotes: 0

Views: 177

Answers (3)

शेखर
शेखर

Reputation: 17614

You can use link button as suggested.
But in my opinion you should not use any server-side control if you don't have to use it on server side.
What you can do create an image tag <img src.... and use onclick event on this image.

When you create a server side controls it is added to your view state key value pair of information. Which is an overhead.

or you can use like this

<a href="javascript:window.print()">
     <img src="print.gif">
</a>

or even

<img src="print.gif" name="pic" onclick="javascript:window.print()"/>

Upvotes: 3

holbrookbw1
holbrookbw1

Reputation: 81

Try this:

<asp:ImageButton ID="submitButton" runat="server" OnClick="submitButton_Click" ImageUrl="~/images/printer.jpg" />

Upvotes: 1

Ian
Ian

Reputation: 34489

You could try the ImageButton class, then you can have a printer icon for example.

Upvotes: 1

Related Questions