如何避免回发链接按钮 [英] how to avoid post back for linkbutton

查看:67
本文介绍了如何避免回发链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行模式下我有gridview如下





Selectbatchdate



2015年5月15日

2015年5月15日

2015年6月16日

Linkbutton



在运行模式下,当我点击链接按钮时,它将回发。



,如何防止链接按钮中的回发



我怎么能在asp.net上用c#

解决方案

如果你不想要回帖那么就不要使用链接按钮是唯一的用途。



 <   asp:LinkBut​​ton     ID   =   MyLink    runat  < span class =code-keyword> =  server    OnClientClick   =  someJsFunction(); return false;   文字  = 链接按钮    /  < span class =code-keyword>>  

< script type = < span class =code-keyword> text / javascript >
function someJsFunction()
{
alert('Hello');
}
< / script >


In Run mode i have gridview as follows


Selectbatchdate

12th may 2015
15th may 2015
16th june 2015
Linkbutton

In run mode when i click the link button it will be postback.

for that how to prevent the postback in link button

for that how can i do in asp.net using c#

解决方案

If you don't want a post back then don't use a link button as that is its only use.

<asp:LinkButton ID="MyLink" runat="server" OnClientClick="someJsFunction(); return false;" Text="Link button" />

<script type="text/javascript">
    function someJsFunction()
    {
        alert('Hello');
    }
</script>


这篇关于如何避免回发链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆