开发者

How to change my server side use of ASP:ImageButton to HTML img tag only

I am trying to wire some fancy Javascript (PopBox) to an ImageButton control and I am getting a very strange run-time (Compilation) error.

<asp:imagebutton id="imgBtnPicture" runat="server" 
      class="PopBoxImageSmall"
      pbshowcaption="true"
      title="Click to magnify/shrink"
      onclick="Pop(this,50,'PopBoxImageLarge');"
      width="90%">
  </asp:imagebutton>

I've looked at replacing the ImageButton web control with a simpler HTML img tag (which is what the PopBox documentation suggests).

Yet, I don't know how to populate an <img> tag from the CodeBehind file. Here is a typical statement which sets the .SRC property from an ASP.Net dataset row:

    Me.imgBtnPicture.Src = theRow.Item("ImageURL")

I've tried this as an alternative:

<img alt="" src="" 
   id="imgPicture" runat="server"class="PopBoxImageSmall" title="Click to magnify/shrink"        
   onclick="Pop(this,50,'PopBoxImageLarge');" width="90%"
/>

Visu开发者_如何转开发al Studio 2008 does not complain about this declaration above but in the codebehind file, how would I address this so I could populate the .Src attribute.

Intellisense, cannot even "see" this

 Me.imgPicture.src = theUrl    'this won't compile...

I added this at the top of the codebehind but seemed to have no effect:

Imports System.Web.UI.HtmlControls


the <asp:imagebutton onclick="..." > is for a server method (code behide).

try with onclientclick


in asp.net imagebutton there is no property class change it to cssclass="PopBoxImageSmall"

then it will work.


It's case sensitive, make sure you're still setting the Src property, capital S...and just remove the src="" from the tag itself so there's no confusion by anyone reading it later:

Me.imgPicture.Src = theUrl
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜