0

How to Closed JQuery UI Dialog Message Box code behind C#.

Below is my Script code.

<script type="text/javascript">
     $("#dialog-message").dialog({
         modal: true,
         draggable: false,
         resizable: false,
         position: ['center', 'top'],
         show: 'blind',
         hide: 'blind',
         width: 400,
         open: function (event, ui) {
             $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
         }

     });

     setInterval(function () {
         $('#dialog-message').dialog('open');
         setTimeout(function () {
             $('#dialog-message').dialog('close');
         }, 10000)
     }, 20000);

</script>

I tried in button code to closed but not working.

protected void Button1_Click(object sender, EventArgs e)
{

    string sliderPopupFunction = @" <script type=""text/javascript""> 
                                $(function () { 
                                    jQuery(function () {
                                        $(""#dialog-message"").dialog(""close""); 
                                    }
                                 });
                            </script>";
    string a = sliderPopupFunction;

}

I need to closed dialog message box using code behind only and also refer this link: Open jQuery UI Dialog from Code Behind

6
  • why you want to close it in code behind? closing from front-end is not enough? Normally, you will wait response from the server if request is successful, if client-side detect the success response then you can now close your dialog Commented Sep 28, 2016 at 5:50
  • The button click will trigger a postback which means the page will reload in the client's browser. If you want to inject scripts into the markup from the code behind you can create a public property on the page and then expose it in the markup using the <%= %> syntax or using the ClientScript.RegisterStartupScript() method. Commented Sep 28, 2016 at 5:52
  • I want to close dialog box in dialog box I had used camera to capture images for every one minute. If user want to closed dailog box If he dont want to take photo from web cam. @Sherlock Commented Sep 28, 2016 at 5:57
  • <asp:Button ID="btnCapture" Text="Capture" runat="server" OnClientClick="return Capture();" onclick="Button1_Click1" /> I am already calling jquery function in my button code for capturing camera photo and If user once capture then dailog should closed. @DanDef Commented Sep 28, 2016 at 6:01
  • @zahed I think you need to either close the dialog box in the Capture() function if you want it to close after every capture or put another button in the dialog box that, when clicked, closes the dialog. You shouldn't be using code-behind to do this. Commented Sep 28, 2016 at 6:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.