Popup

It is initialized using Html.Awe().InitPopup() and after opened using awe.open js function.

There's also the PopupForm helper which is used in all of the Crud demos (Grid, AjaxList), also in the Wizard Demo, the PopupForm handles form posts that happen inside it and has 2 buttons by default (OK, Cancel).

Initialize and open popup on button click

PopupDemo/Index.cshtml
@(Html.Awe().InitPopup()
.Name("popup1")
.Url(Url.Action("Meals"))
.LoadOnce()
.Title("meals list popup")
.Width(500)
.Height(450))

@Html.Awe().Button().Text("Open Popup").OnClick(Html.Awe().OpenPopup("popup1"))
Demos/Helpers/PopupDemoController.cs
public ActionResult Meals()
{
return PartialView();
}
PopupDemo/Meals.cshtml
@Html.Awe().AjaxList("Meals").CssClass("fixedheight")

<style>
.fixedheight
{
height:370px;
overflow-y: scroll;
}
</style>

DropdownPopup Mod

PopupDemo/Index.cshtml
@(Html.Awe().InitPopup()
.Name("popupdd1")
.Url(Url.Action("DropdownContent"))
.LoadOnce()
.Title("meals list popup")
.Mod(o => o.Dropdown())
.Width(300))

@Html.Awe().Button().Text("open dropdown popup").OnClick(Html.Awe().OpenPopup("popupdd1"))
@Html.Awe().Button().Text("open dropdown popup").OnClick(Html.Awe().OpenPopup("popupdd1"))
Demos/Helpers/PopupDemoController.cs
public ActionResult DropdownContent()
{
return PartialView();
}
PopupDemo/DropdownContent.cshtml
<div style="max-width: 250px;">
Popup content loaded from the server at @(DateTime.UtcNow.ToLongTimeString()) UTC
</div>

Sending client side paramters to server on content load

Value sent to the server action that returns the popup's content:
PopupDemo/Index.cshtml
<input type="text" id="txtParam1" value="abc" />

<br />

@(Html.Awe().InitPopup()
.Name("PopupParams")
.Url(Url.Action("PopupWithParameters"))
.Parent("txtParam1")
.Parameter("p1", 15)
.ParameterFunc("giveParams"))

@(Html.Awe().Button().Text("Open Popup")
.OnClick(Html.Awe().OpenPopup("PopupParams").Params(new { Id = 123})))

<script>
function giveParams() {
return { a: "hi", b: "how are you" };
}
</script>
Demos/Helpers/PopupDemoController.cs
public ActionResult PopupWithParameters(string parent, int p1, string a, string b, int id)
{
ViewData["parent"] = parent;
ViewData["p1"] = p1;
ViewData["a"] = a;
ViewData["b"] = b;
ViewData["id"] = id;

return PartialView();
}
PopupDemo/PopupWithParameters.cshtml
value of the parent: @ViewData["parent"] <br/>
value of the p1 parameter: @ViewData["p1"] <br/>
parameters sent by js function set using ParameterFunc:<br/>
a: @ViewData["a"] <br/>
b: @ViewData["b"] <br/>
id: @ViewData["id"]

Full screen popup

PopupDemo/Index.cshtml
@(Html.Awe().InitPopup()
.Name("psize")
.Url(Url.Action("PopupSize"))
.Fullscreen())

@Html.Awe().Button().Text("Open").OnClick(Html.Awe().OpenPopup("psize"))

Buttons

PopupDemo/Index.cshtml
<div id="p3Cont"></div>
@(Html.Awe().InitPopup().Name("p3")
.Button("Add Hi", "addHi")
.Button("Say Hi", "sayHi")
.Button("Close", "closePopup")
.Url(Url.Action("PopupBtns"))
.Close("onClose")
.Tags("p3Cont") /* used by the inline popup only */)

@Html.Awe().Button().Text("Open popup with buttons").OnClick(Html.Awe().OpenPopup("p3"))
<script type="text/javascript">
function closePopup() {
$(this).data('api').close();
}

function sayHi() {
alert('hi');
}

function addHi() {
$(this).prepend('<p>hi</p>');
}

function onClose() {
alert('popup was closed');
}

</script>

Mods

By default the awesome popup is used for the popup, but this can be changed by setting the awe.popup. You may choose to use just one or multiple popup mods. In the top right corner you can see a dropdown that allows you to change the current popup mod, this dropdown changes the value of popupMod variable which is used in the following code:
Site.js
//this code uses popupMod variable specific to this demo, you shouldn't need this, 
//use utils.setPopup to be able to use the DropdownPopup and Inline (already called in utils.init)
function setAweDemoPopup() {
awe.popup = function (o) {
if (o.tag && o.tag.DropdownPopup) {
return awem.dropdownPopup(o);
} else if (o.tag && o.tag.Inline) {
return awem.inlinePopup(o);
} else if (popupMod == 'inline') {
return awem.inlinePopup(o);
} else if (popupMod == 'bootstrap') {
return awem.bootstrapPopup(o);
} else if (popupMod == 'awesome') {
return awem.dropdownPopup(o);
} else {
return awem.uiPopup(o);
}
};
}
o.tag.Inline is necessary for Grid in nest editing demo, if you set .Tag(new{Inline = true}) the inline popup will be used regardless of popupMod value.

Autosize

Open any popup and try resizing the browser (try to make it smaller than the popup), works for popups from other helpers as well.

Notes

When there is more Popup helpers declared that have the same .Name(string), they will share the same popup window, so opening one will close the other; if you need to have popups with different names to share the same popup window use .Group(string).