Tuesday, November 7, 2017

Design Own alert in MVC

alert(new MyResult { Message = "Panel Saved Succesfully.", Tittle = "Create/Update Panel" });
===========================================
public class MyResult
{
public bool restype { get; set; }

public string Message { get; set; }

public string Tittle { get; set; }

public string ClassName
{
get
{
if (restype)
{
return "ui-icon ui-icon-circle-check";
}
else
{
return "ui-icon ui-icon-alert";
}
}
}
}


===============MasterLayout
@if (TempData["Result"] != null)
{
<div>@Html.Partial("_MyResult", TempData["Result"] as DAL.Models.MyResult)</div>
}


====================Partial view========================
_MyResult.cshtml



@model DAL.Models.MyResult

@if (Model != null)
{
<div id="div_result_dialog">
@**@

<label> @Html.Raw(HttpUtility.HtmlDecode(Model.Message))</label>
@Html.HiddenFor(model => model.Tittle, new { @id = "res_tittle_id" })

</div>
}
<script type="text/javascript">
$(document).ready(function () {
var IsRads = $(".contentcontnrPadng").hasClass("RadsOuter");
if ($('#div_result_dialog').length != 0) {

$("#div_result_dialog").dialog({
modal: true,
dialogClass: IsRads ? "RadsOuter" : null,
title: $('#res_tittle_id').val(),
buttons: {
Ok: function () {
$(this).dialog("close");
}
}
});
}
});
</script>


No comments:

Post a Comment

javascript Filter/index off

 var family = [{"name":"Jack",  "age": 26},               {"name":"Jill",  "age"...