最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to show a popup on click of Asp.Net Button click event - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question edited Jun 7, 2012 at 5:42 Priyank Patel asked Jun 7, 2012 at 5:35 Priyank PatelPriyank Patel 7,00611 gold badges62 silver badges88 bronze badges 3
  • like this js_popup – PresleyDias Commented Jun 7, 2012 at 5:40
  • @jflood I posted my popup html and css – Priyank Patel Commented Jun 7, 2012 at 5:43
  • what about your click event handler in the code behind? – jflood Commented Jun 7, 2012 at 5:52
Add a ment  | 

2 Answers 2

Reset to default 1

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.");
}

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;
发布评论

评论列表(0)

  1. 暂无评论