链接按钮回发两次 [英] Link button postback twice

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

问题描述

在我的default.aspx中,我有一个div,该div具有用于高级搜索的链接按钮.当我单击此链接按钮时,我要在default.aspx上存在的iframe中打开一个页面.
我的链接按钮的代码是

In my default.aspx I am having a div which has linkbutton for Advanced search. When i click on this link button I want to open a page in the iframe present on default.aspx.
Code for my link button is

<asp:LinkButton runat="server" ID="lbAdvancedSearch"
Text="Advanced Search" ForeColor="Black" onClientClick="javascript:OpenAdvancedSearch();"></asp:LinkButton>



和javascript函数类似:



And javascript function is like:

function OpenAdvancedSearch() {
          window.open(''Cases.aspx?Search=1&IsAdvancedSearch=1'', ''CenterTop'');
      }




除此之外,我还尝试在page_load事件中为onclick事件添加属性.

但是,无论我尝试使用哪种Page_Load事件,在单击链接按钮时都会被调用两次.

请帮助..




Apart from this I also tried adding attributes for onclick event in page_load event.

But whatever i try Page_Load event is called twice on clicking link button.

please help..

推荐答案

我认为您需要在调用如下所示的OpenAdvancedSearch方法后添加return false;语句.
如果只允许调用open函数,则可以使用简单的anchor标记,例如:

I think you need to add the return false; statement after you call the OpenAdvancedSearch method as shown below.

If you want to allow only the open function to be called, you can use a simple anchor tag like:

<a href="#" onclick="javascript:OpenAdvancedSearch(); return false;">Advance Search</a>



或者,如果您想继续使用现有代码,只需在末尾添加return false;,如下所示:



Or if you want to continue with the existing code, just add return false; at the end like this:

<asp:linkbutton runat="server" id="lbAdvancedSearch" xmlns:asp="#unknown">
Text="Advanced Search" ForeColor="Black" onClientClick="javascript:OpenAdvancedSearch(); return false;"></asp:linkbutton>



return false;语句将避免回发.



The return false; statement will avoid the postback.


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

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