labfibeethift
New Member
I want to execute some client side script at the click of a button. It works , but still the form post back occurs after execution. How do I avoid this postback after execution ?<BR><BR>Sample Code:<BR>-----------<BR><html><BR><head><BR><script language="javascript"><BR> <!--<BR> function test()<BR> {<BR> alert ("Client Side Test"); <BR> }<BR> // --><BR></script><BR></head><BR><body><BR><form id="frm_ModelSearch" method="post" runat="server"><BR><asp:Table runat=server><BR> <asp:TableRow><BR> <asp:TableCell HorizontalAlign="Center" VerticalAlign="Top"><BR> <table><BR> <tr><BR> <td align="left"><BR> <input type="image" runat="server" src="right.gif" id="btn_ViewAddFields" <BR> onClick="javascript: return test()"><BR> </td><BR> </tr><BR> </table><BR> </asp:TableCell><BR> </asp:TableRow><BR></aspTable><BR></form><BR></body><BR></html><BR><BR>Thanks,<BR>Sinchana<BR> <BR>Don't use a server control. Just take out the "runat='server'" part.I have tried this. But still the page is getting posted back. I have given a breakpoint at the Page-Load method. At the click of the button, the alert message is displayed and then the control goes back to page-load.Try adding a return false at the end of your javascript test function.I had totally forgotten about this tip/trick which I had used in my earlier assignments. Thanks a lot for reminding.