I've below asp buttons
in radAjax:RadAjaxPanel
control which has OnClientClick
event -
<radAjax:RadAjaxPanel ID="Panel" runat="server" LoadingPanelID="Loadingpanel6">
<table>
<tr>
<td>
<b>Sort by :</b>
</td>
<td>
<asp:Button ID="btnMostRecent" Text="Most Recent" class="button action sortcomments"
runat="server" OnCommand="btnMostRecent_Click" OnClientClick="(document.getElementById('hdnSortOrder')).value='date'" CommandArgument="date" />
</td>
<td>
<asp:Button ID="btnMostViewed" Text="Most Viewed" class="Comments" runat="server"
OnCommand="btnMostViewed_Click" OnClientClick="(document.getElementById('hdnSortOrder')).value='views'" CommandArgument="views" />
</td>
</tr>
</table>
<radAjax:AjaxLoadingPanel ID="Loadingpanel6" runat="server">
<asp:Image ID="Image1" runat="server" AlternateText="Loading" BorderWidth="0px" ImageUrl="/themes/mercolaarticle/images/loading6.gif" />
</radAjax:AjaxLoadingPanel>
</radAjax:AjaxLoadingPanel>
When i click
on any of the button
the page PostBack
which i want to avoid
.
FYI - Buttons
are in RadAjaxPanel
.
Any suggestion
or help
.!! Thanks in advance..:)
Return false in OnClientClick ie -
OnClientClick="(document.getElementById('hdnSortOrder')).value='views'; return false;"
Be aware that this means post back will never occur on that button.
If you return false from your client click function then postback will not happen.
like
<asp:button runat="server" id="btn" OnClientClick="return myFunc();"/>
and script block is
<script>
function myFunc()
{
return false;
}
</script>
Just use this:
<asp:button runat="server" id="btn" OnClientClick="myFunc(); return false;"/>
and then:
<script>
function myFunc(){
//Do your javascript code here
}
</script>
如果要避免从按钮控件回发,只需从函数中返回false即可。
<asp:button runat="server" id="btnTest" OnClientClick="anyFunction() return false;"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.