tags:

views:

442

answers:

2

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
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
Thanks Chris. Problem solved.