---
title: "JQuery ui dialog is not opening on button click when auto open is set to false"  
description: "JQuery ui dialog is not opening on button click when auto open is set to false"  
author: "Anonymous User"  
published: 2015-04-01  
updated: 2015-04-01  
canonical: https://www.mindstick.com/forum/23072/jquery-ui-dialog-is-not-opening-on-button-click-when-auto-open-is-set-to-false  
category: "javascript"  
tags: ["jquery", "jquery ui"]  
reading_time: 2 minutes  

---

# JQuery ui dialog is not opening on button click when auto open is set to false

I’m using [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [forms](https://www.mindstick.com/interview/34192/what-is-the-purpose-of-the-authentication-mode-forms-element-in-web-config) this [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) I’m working on has a master page it works great when autopen is false but when [auto](https://www.mindstick.com/forum/33810/remote-view-in-android-auto-cancel-custom-notification) false is [true](https://yourviews.mindstick.com/view/81326/boycott-chinese-products-dream-will-come-true) I don’t know why it doesn’t work. [Code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) is.

```
$(document).ready (function () {         
$("#dialog").dialog({            autoOpen:false,            appendTo:"form",             show: {               
effect: "fade",               duration: 1000            },                            
hide: {               
effect: "explode",               
duration: 1000            },             buttons: {                Ok:
function () {                   
$("[id*=btnmsgOk]").click();                   
$(this).dialog("close");                },               
Cancel: function () {                   
$(this).dialog("close");                }            }        });  });
```

and i call this [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) by this..

```
$('<%=btnSave.ClientID %>').click(function () {            
$("#dialog").dialog("open");          });
```

but it dosent work.

## Replies

### Reply by Elena Glibart

I have tried following, it is working fine. Please note that , you have missed to put # in jquery selector. It should be $('#<%=btnSave.ClientID %>').click...

```
$(document).ready(function() {  $("#dialog").dialog({    autoOpen: false,    appendTo: "form",    show: {      effect: "fade",      duration: 1000    },    hide: {      effect: "explode",      duration: 1000    },    buttons: {      Ok: function() {        $("[id*=btnmsgOk]").click();        $(this).dialog("close");      },      Cancel: function() {        $(this).dialog("close");      }    }  });});$("#clicktoopen").click(function() {  $('#dialog').dialog('open');});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script><link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/humanity/jquery-ui.css" type="text/css" /><div id="dialog">DIV</div><button id="btnmsgOk" value="btn" style="display:none">Ok</button><button id="clicktoopen" value="click">Click</button>
```


---

Original Source: https://www.mindstick.com/forum/23072/jquery-ui-dialog-is-not-opening-on-button-click-when-auto-open-is-set-to-false

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
