我有一個ImageButton被構建在radgridview columnn內部。它被定義如下。ImageButton不符合codebind方法,但如果替換爲LinkButton
<asp:ImageButton ID="ImageButton_DeleteRun" ImageUrl="~/Assets/Images/Misc/delete.png"
runat="server" OnClick="QueryDelete" CommandName="QueryDelete"
CommandArgument='<%# DataBinder.Eval(Container,"DataItem.QueryGuid") %>'
Width="10" Height="10" />
它加載正確。當我點擊它時,我預計會碰到以下代碼隱藏方法:
protected void QueryDelete(object sender, EventArgs e)
{
/* A bunch of code*/
}
它永遠不會到達那裏。更值得一提的是,如果我將ImageButton替換成
<asp:LinkButton ID="ImageButton_DeleteRun" Text="X"
runat="server" OnClick="QueryDelete" CommandName="QueryDelete"
CommandArgument='<%# DataBinder.Eval(Container,"DataItem.QueryGuid") %>'/>
它完美地工作。 ImageButton有什麼問題嗎?我錯過了什麼嗎?
編輯 - 新信息
基本上當圖像按鈕呈現,沒有HREF。
Weird--
<input type="image" style="height: 10px; width: 10px; border-width: 0px;" src="../Assets/Images/Misc/delete.jpg"
id="ctl00_ctl00_ctl00_AllContent_MainContent_MainContent_controlPanelQueryHistory_saved_RadGridQueryHistory_ctl00_ctl04_ImageButton1"
name="ctl00$ctl00$ctl00$AllContent$MainContent$MainContent$controlPanelQueryHistory_saved$RadGridQueryHistory$ctl00$ctl04$ImageButton1"/>
<a
href="javascript:__doPostBack('ctl00$ctl00$ctl00$AllContent$MainContent$MainContent$controlPanelQueryHistory_saved$RadGridQueryHistory$ctl00$ctl04$ImageButton_DeleteRun','')"
id="ctl00_ctl00_ctl00_AllContent_MainContent_MainContent_controlPanelQueryHistory_saved_RadGridQueryHistory_ctl00_ctl04_ImageButton_DeleteRun">delete</a>
剛剛試了一下,沒有運氣:-( – Matt 2009-11-12 23:43:00