1
我有一個複選框的頁面,用戶應該檢查並彈出一個窗口將顯示。彈出的窗口顯示正確;然而,我一直無法讓窗戶關閉。正如你在下面看到的,只要用戶點擊提交,就會調用closewindow函數。該消息顯示,但窗口從不關閉。請參閱以下示例代碼。Telerik Control彈出窗口拒絕關閉
//This is the content of the partial page that is being load in the popped up window.
@using (Html.BeginForm("StudentArchive", "Arvhive", FormMethod.Post, new { onsubmit = "CloseWindow()" }))
{
@Html.HiddenFor(item => item.StudentID)
<table>
<tr>
<th>
Student Archive Reason
</th>
</tr>
<tr>
<td>
@Html.TextAreaFor(item => item.ArchiveReason)
</td>
</tr>
</table>
<input type="submit" value="Submit" name="btnSubmit" id="ArchiveReasonSubmit" onclick="CloseWindow();" />
}
<script type="text/javascript">
function CloseWindow() {
alert('I am closing window in reason for archive');
$("#Window").data("tWindow").close();
// $('#Window').prop("checked", "checked");
// window.location.href = window.location.href;
}
</script>
//this script is in a studentDetails page which is where the checkbox that would open the window below located.
<script type="text/javascript">
function chkArchive() {
var s = document.getElementById('archiveCheckBox').checked;
if (s == true) {
OpenWindow(this);
}
if (s == false) {
alert('checkbox is unchecked');
}
}
</script>
<script type="text/javascript">
function OpenWindow(e) {
var checkbox = document.getElementById('archiveCheckBox').value;
if (checkbox == "false") {
alert('It is false.');
} else if (checkbox == "true") {
$('#Window').data('tWindow').center().open();
}
}
</script>
<script type="text/javascript">
function ClosingWindow() {
$('#Window').prop("checked", "checked");
window.location.href = window.location.href;
}
</script>
@{Html.Telerik().Window()
.Name("Window")
.Visible(true)
.Title("Reason for Archives")
.Modal(true)
.Height(600)
.Draggable(true)
.Visible(false) //I could have added a variable set the default value to false to hide the window. However, I am not sure how to change it back to
//yes after the user checks the checkbox for the first time. The only event that fire when a user check the checkbox is the javascript event to check the state
// of the checkbox and open the window.
.Width(800)
.ClientEvents(events => events.OnClose("ClosingWindow"))
.LoadContentFrom(Url.Action("StudentArchive", "Student", new { StudentID = @ViewData["StudentID"] }, Request.Url.Scheme))
.HtmlAttributes(new { onsubmit = "CloseWindow()" })
.Render();
}
首先鏈接,你在兩個地方使用closewindow()函數,嘗試刪除one.second檢查你得到JavaScript錯誤。 – sathishkumar 2013-02-10 17:12:45
jquery庫被引用兩次。我從部分視圖頁面中刪除它,查詢工作正常。 http://www.telerik.com/community/forums/aspnet-mvc/window/close-modal-window-from-within-the-window.aspx – Gagouche 2013-02-10 20:51:45