How to use jQuery UI dialog in asp.net


jQuery is the top cross-browser javascript library used in most web projects now.
I decided to blog this in how to add jQuery UI in ASP.Net 3.5 projects as my reference.

Lets get started!

First add this javascript reference in your web form or in webmaster.

1 <script src="js/jquery.js" type="text/javascript"><!--mce:0--></script>
2 <script src="js/ui/ui.core.js" type="text/javascript"><!--mce:1--></script>
3 <script src="js/ui/ui.draggable.js" type="text/javascript"><!--mce:2--></script>
4 <script src="js/ui/ui.resizable.js" type="text/javascript"><!--mce:3--></script>
5 <script src="js/ui/ui.dialog.js" type="text/javascript"><!--mce:4--></script>

you can download this in jQuery UI website

Then add an input button with an ID name btnAdd a div for you dialog and a div for status

1 <input id="btnAdd" value="add" type="button">

Add a javascript function on calling the dialog.

01 function openDialog() {
02
03 var $dialog = jQuery('#dialog');
04
05 $dialog.load('dialog/Item.aspx');
06 $dialog.dialog({
07 autoOpen: false,
08 title: 'Add New Contact Personel',
09 modal: true,
10 height: 250,
11 width: 400,
12 show: 'puff',
13 hide: 'puff',
14 close: function (event, ui) {
15 $dialog.html('');
16 $dialog.dialog('destroy');
17 }
18 });
19 $dialog.dialog('open');
20 }

Each time you click the button this will be triggered

1 $(document).ready(function () {
2 jQuery("#btnAdd").click(function () {
3 openDialog();
4 });
5 });

2 thoughts on “How to use jQuery UI dialog in asp.net

  1. Howdy! I am aware this can be somewhat away matter however i wondered if you knew where I possibly could choose a captcha wordpress plugin regarding my personal opinion kind? I’m employing the same website program since yours and I’m having difficulty obtaining 1? Thanks a lot!

  2. How would you do it in this example: only show the dialog if the you successfully do something on the server side of your button click event?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s