c# - MVC3 Razor and Modal popup -


i need modal popup displays form save data db. there example of doing it? ajax more flexible or using jquery dialog?

i've used jquery ui dialog plugin , use jquery load modal dialog via ajax, , quite happy it.

i've had hack code give useful, apologies syntax errors, use jquery,

$('#myatag').click(function () {     // add container modal dialog, or existing 1     var dialog = ($('#modaldialog').length > 0) ? $('#modaldialog') : $('<div id="modaldialog" style="display:hidden"></div>').appendto('body');     // load data via ajax     $.get( 'mycontroller/myaction', {},         function (responsetext, textstatus, xmlhttprequest) {             dialog.html(responsetext);             dialog.dialog({                 bgiframe: true,                 modal: true,                 width: 940,                 title: 'my title'             });          }     ); }); 

which binds call ajax 'get' 'click' event of link. ajax request returns partial view corresponding action in mvc projec, shows in modal dialog.

here rough example of controller like

    public actionresult myaction()     {         // stuff         //...          // if request ajax one, return partial view         if (request.isajaxrequest())             return partialview("partialviewname");          // else return normal view         return view();     } 

the view dialog normal partial view.

i use following .css, 'greys out' page behind modal dialog

.ui-widget-overlay {     position: absolute;     top: 0;     left: 0;     width: 100%;     height: 100%;     background: #aaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;     opacity: .8;     filter: alpha(opacity=30); } 

you might need muck around css #modaldialog looking right,


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -