Modal form in ASP.NET using jQuery

I am relatively new to ASP.NET development, so far I managed to keep everything simple, but now I have a slightly more complicated requirement and still do not get much joy.

Essentially, I want the modal form to pop up at the click of a button to add a new user, so I found this on the jQuery site , which I think is what I'm looking for, but I'm really trying to figure out how this can be added to the ASP.NET project / page.

Any advice would be much appreciated thank you!

+6
source share
1 answer

You need to include jQuery and jQuery UI reference.

Then you need to create a container for your dialog, for example:

  <div id="dialog"> <p> Your content here </p> </div> 

Then you need to create a dialog, that is, when the DOM loads:

  $(document).ready(function() { $("#dialog").dialog({ autoOpen: false, height: 200, width: 200 }); }); 

Then, to open the dialog with a button, you can add a simple HTML button and attach it via jQuery.

 <input type="button" ID="btnDialog" value="Click here to open the dialog" /> 

Then attach to jQuery :

 $("#btnDialog").click(function() { $("#dialog").dialog("open"); }); 

JS Fiddle: http://jsfiddle.net/VtZYD/

Make sure jQuery as well as jQuery UI loaded

This should be placed in your <head> section:

  <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src=http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 

You can also add CSS files using the link tag:

  <link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" /> 
+11
source

Source: https://habr.com/ru/post/953037/


All Articles