我在视图中有一个名为index.cshtml的jquery函数'ShowerrorDialog',我需要从另一个视图test.cshtml中调用相同的函数。
function ShowerrorDialog(msg) {
$("#errorDialog").html(msg);
$("#errorDialog").dialog({ modal: true,
dialogClass:'errorDialogClass',
buttons: {
"OK" : function() {
$( "#errorDialog" ).dialog("close");
}
}
});
}
test.cshtml:
@model IEnumerable<Ad_hocReporting.Models.GridModel>
@{
Layout = null;
}
@{
if (@Model.First().message == "Session Out")
{
//need to call ShowerrorDialog here
}
else
{
var grid = new WebGrid(Model, ajaxUpdateContainerId: "popup_content", rowsPerPage: 7);
grid.Pager(WebGridPagerModes.NextPrevious);
<div id="popup_content">
@grid.GetHtml(tableStyle: "webGrid", rowStyle: "webGridRow", headerStyle: "webGridHeader", footerStyle: "webgridFooter", alternatingRowStyle: "webGridAlternateRow", columns: grid.Columns(
grid.Column("QueryTitle", (format: @<label>@item.QueryTitle</label>), header: "Query Name", style: "color:gray"),
grid.Column((format: @<a href="#" onclick="javascript:OnEdit(this.id,'@item.QueryTitle');" class="selectcss" id=@item.QueryId>Select</a>), header: "Select"),
grid.Column((format: @<input type="image" src="../../Content/images/DeleteRed.png" alt="delete" class="deletecss" onclick="javascript:OnDelete(this.id);" id=@item.QueryId'delete' />), header: "Delete")))
</div>
}
}
答案 0 :(得分:0)
您可以将该函数插入到通用文件中,并使用标记include
来使用它。