Priyank Patel
Priyank Patel

Reputation: 6996

How to show a popup on click of Asp.Net Button click event

I have a popup which displays a message to the user which says their information has been submitted.The popup div's id NewCustomerStatusPopUp,I want this popup to be displayed when the information has been successfully inserted in the database , so how do I call the javascript function to show popup when all the information has been submitted.Can any one just let me know how can I do this. Here is my popup

<div id="NewCustomerStatusPopUp">
<asp:Label ID="lblStatus" Text="" runat="server"/>
</div>

CSS:

#NewCustomerStatusPopUp
    {
    position: fixed;
    width: 300px;
    height: 250px;
    top: 50%;
    left: 50%;
    margin-left:-255px;
    margin-top:-150px;
    border: 10px solid #9cc3f7;
    background-color:White; 
    padding: 10px;
    z-index: 102;
    font-family:Verdana;
    font-size: 10pt;
    border-radius:10px;
    -webkit-border-radius:20px;
    -moz-border-radius:20px;

    }

Any help is much appreciated.

Thanks.

Upvotes: 1

Views: 14868

Answers (2)

Nikhil D
Nikhil D

Reputation: 2509

To call a javascript function from server you can use a RegisterStartipScript:
After ur insert query write this code

ClientScript.RegisterStartupScript(GetType(), "id", "callMyJSFunction()", true);

<script type="text/javascript">
function callMyJSFunction()
{
    alert("Record inserted sucessfully.");
}

Upvotes: 1

jflood.net
jflood.net

Reputation: 2456

If you've got an click event handler in your code behind performing the insert, no need for JS, wrap the div in a panel:

<asp:Panel ID="pnlStatus" Visible="false" >
    <div id="NewCustomerStatusPopUp">
      <asp:Label ID="lblStatus" Text="" runat="server"/>
    </div>
</asp:Panel>

In your code behind, once you've asserted that the new customer was added successfully,

set pnlStatus to visible.

pnlStatus.Visible = true;

Upvotes: 1

Related Questions