链接按钮回发两次
在我的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 thereturn false;
statement after you call theOpenAdvancedSearch
method as shown below.
If you want to allow only the open function to be called, you can use a simpleanchor
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.