Search code examples
asp.net.netuser-interfaceweb-parts

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?


Solution

  • 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()"/>