简体   繁体   English

如何避免在Imageview中单击回发网格视图

[英]How to avoid postback on a Image button click in gridview

my code for the button is 我的按钮代码是

<asp:ButtonField ButtonType="Image" CommandName="Edit"
                                    ImageUrl="~/images/edit.png" ShowHeader="True" CausesValidation="false"/>

You can use a simple HTML control instead of an ASP.NET Web Control. 您可以使用简单的HTML控件代替ASP.NET Web控件。 If you can't, use Javascript in the OnClick Event 如果不能,请在OnClick事件中使用Javascript

Use javascript - using the onclick client event 使用JavaScript-使用onclick客户端事件

    <asp:ButtonField ButtonType="Image" CommandName="Edit" onClick="return false;"                                    
ImageUrl="~/images/edit.png" ShowHeader="True" 
                                        CausesValidation="false"
                                        />

I think what you're looking for is this: 我认为您正在寻找的是:

        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <img src="~/images/edit.png" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM