asp.net button as image

liunx

Guest
how can I change a button to show an image

<asp:button id="Button" runat="server" Width="121px" Text="Test"></asp:button>


should still be a button but show an image that i set.
what is the correct code for this?<asp:imagebutton id="ImgButton" runat="server" src=http://www.webdeveloper.com/forum/archive/index.php/"path/to/image.gif" />it's strange -- if I use your code then I see the button but it doesn't work (process the code)

If I change the id to the id of my button then I get an error.
I'm very new to .net
What am I missing out on?The event arguments for a normal button and an Image button are different. A button is like this:

Private Sub btnButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnButton.Click


And an image button is like this:

Private Sub btnImage_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnImage.Click


Since you are new, I'd recommend that you look at the tutorials section of <!-- w --><a class="postlink" href="http://www.asp.net">www.asp.net</a><!-- w -->, once you have gone through that and played with controls, code, etc. and become comfortable with .Net, then I'd recommend that you take a look at these sites. I'm sure that if you start a thread requesting good .Net websites, you'll get a bunch more good links.:
<!-- w --><a class="postlink" href="http://www.4guysfromrolla.com">www.4guysfromrolla.com</a><!-- w -->
<!-- w --><a class="postlink" href="http://www.codeproject.com">www.codeproject.com</a><!-- w -->
MSDN .Net Framework Reference:
<!-- m --><a class="postlink" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netstart/html/cpframeworkref_start.asphi">http://msdn.microsoft.com/library/defau ... tart.asphi</a><!-- m --> thanks for your help

i changed the sub as you suggested -- I now see the button but nothing is happening when I click it. Any ideas?Do you have your script on the same page as your html? If so, the html for the button should look something like this.

<asp:imagebutton id="btnImage" src=http://www.webdeveloper.com/forum/archive/index.php/"path/to/image.gif" onclick="btnImage_Click" runat="server" />it's on the page .aspx.vb behind my page.

I even tried putting a class to a regular button with an image but it ignored it.

Asp.net is really much different then asp i see.
 
Top