locked
How do i use model popup to display server side message on data submission RRS feed

  • Question

  • User-2074858223 posted

    How do i use model popup to display server side message on data submission, example if a user wants to submit record to database , how do i use model popup to display "Data submitted successfully!", instead of using window popup like this:

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Please quantity required is more than the stock, Stock is 1 or less than 1, update stock ... !!')</script>", false);
                                                                                    }
                                                                                }

    Wednesday, August 12, 2015 12:19 PM

All replies

  • User-1373846979 posted

    In View Page:

    -------------------

    <asp:Button ID="btnShowPopup" runat="server" Style="displaynone" onclick="btn_click"/>
    <ajaxtoolkit:ModalPopupExtender BackgroundCssClass="modalBackground" CancelControlID="btnClose"
        runat="server" PopupControlID="pnl1" ID="mdlPanel" TargetControlID="btnShowPopup" />
    
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                
                <td align="right">
                    <asp:ImageButton ID="btnClose" Height="25px" runat="server" ImageUrl="~/images/Button_Close.png"
                        CausesValidation="false" />
                </td>
            </tr>
    <tr>
               <td>
                    <asp:Label ID="lbl" runat="server" Text="Panel"></asp:Label>
                </td>
            </tr>

    </table>
    </asp:Panel>
    In .cs Page
    --------------------------------

    //if u want to display the popup on button-click then use the following code in the button click event of ur code behind page

    protected void btn_click(Object sender, EventArgs e)
    {
    lbl.Text="Data Submitted Sucessfully";
    mdlPanel.Show();
    }
     
    Thursday, August 13, 2015 12:47 AM
  • User-1373846979 posted

    In View Page

    -----------------------

    <asp:Button ID="btnShowPopup" runat="server" Style="display: none" onclick="btn_click"/>
    <ajaxtoolkit:ModalPopupExtender BackgroundCssClass="modalBackground" CancelControlID="btnClose"
    runat="server" PopupControlID="pnl1" ID="mdlPanel" TargetControlID="btnShowPopup" />

    <asp:Panel ID="pnl1" runat="server">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>

            <td align="right">
                <asp:ImageButton ID="btnClose" Height="25px" runat="server" ImageUrl="~/images/Button_Close.png"
                    CausesValidation="false" />
              </td>
        </tr>
        <tr>
           <td>
               <asp:Label ID="lbl" runat="server" Text="Panel"></asp:Label>
          </td>
      </tr>

      </table>
    </asp:Panel>


    In .cs Page
    --------------------------------

    //if u want to display the popup on button-click then use the following code in the button click event of ur code behind page

    protected void btn_click(Object sender, EventArgs e)
    {
    lbl.Text="Data Submitted Sucessfully";
    mdlPanel.Show();
    }

    Thursday, August 13, 2015 12:54 AM
  • User-2074858223 posted

    This is how i display data submitted successfully when submitting data on button click

     }
                                                                                    else
                                                                                    {
                                                                                        ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Please quantity required is more than the stock, Stock is 1 or less than 1, update stock ... !!')</script>", false);
                                                                                    }
                                                                                }

    But now i want to use bootstrap model the display the message, your example seems not to be working:

    Here is the model i want to use:

     <script type="text/javascript">
                                                    $("[id*=btnSave]").live("click", function () {
                                                        $("#dialog").dialog({
                                                            title: "jQuery Dialog Popup",
                                                            buttons: {
                                                                Close: function () {
                                                                    $(this).dialog('close');
                                                                }
                                                            }
                                                        });
                                                        return false;
                                                    });
    </script>
    <div id="dialog" style="display: none">
        This is a simple popup
    </div>
    


    Thursday, August 13, 2015 3:59 AM
  • User177399542 posted

    Hi 

           micah In order to call jquery or javascript function from asp .net code behind follow :

    http://www.codingfusion.com/Post/Call-JavaScript-function-from-Code-behind-Server

    Friday, August 14, 2015 6:20 AM
  • User-219423983 posted

    Hi micah2012,

    As a supplement, according to the model you want to use, I think it’s better for you to take a look at the following article, it provides a complete demo based on the expected mode. According to the article, it creates a function to accept a variable and set it to the dialog content. About how to call this JS function from the server side, it uses ClientScript. RegisterStartupScript () to achieve it.

    <script type="text/javascript">
        function ShowPopup(message) {
            $(function () {
                $("#dialog").html(message);
                $("#dialog").dialog({
                    title: "jQuery Dialog Popup",
                    buttons: {
                        Close: function () {
                            $(this).dialog('close');
                        }
                    },
                    modal: true
                });
            });
        };
    </script>

    http://www.aspsnippets.com/Articles/Open-Show-jQuery-UI-Dialog-Popup-Window-from-Server-Side-Code-Behind-in-ASPNet.aspx

    I hope it’s useful to you.

    Best Regards,

    Weibo Zhang

    Sunday, August 23, 2015 5:40 AM