I want to show a popup on click of a button. I am able to achieve it but I was not able to stop autopostback. The pop-up is displayed and page gets posted back automatically. Need help. TIA.
+3
A:
I assume you're doing something like this in Javascript to open the popup:
<input type="submit" onclick="window.open('...');" ... />
All you need to do is add "return false;" to the end of your Javascript call to prevent the postback from occurring, leaving you with something like:
<input type="submit" onclick="window.open('...'); return false;" ... />
bcwood
2009-06-20 04:43:27
A:
Here's an example using the LinkButton's OnClientClick property:
protected void lnkConfirm_Click(object sender, EventArgs e)
{
Response.Write("Postback!");
}
<asp:LinkButton ID="lnkConfirm" runat="server"
OnClientClick="return confirm('Do Postback?');"
OnClick="lnkConfirm_Click">Postback</asp:LinkButton>
Chris
2009-06-20 05:03:08
Thanks Chris. Problem solved.
2009-06-25 06:08:58