我想就一个独特的处理问题获得一些帮助。考虑到这些限制,我正在寻找一个特定的解决方案。
我有一个弹出 aspx 页面,它从父页面 gridview 编辑单击接收数据。当数据在弹出窗口中翻译时,从父页面解析大量数据以弹出,然后在更新前发送回父页面以在原始文本块中重新组合。
当弹窗传回数据或被取消时,父页面gridview仍处于编辑模式。
我想将弹出窗口中的取消或更新按钮单击传递给父页面gridview,这样它就可以完成更新或取消事件,而无需要求用户从gridview编辑模式单击相应的命令按钮链接来更新或取消。
我真的在寻找教程、链接或示例代码,因为我想完全了解如何做到这一点。
更新:父页面上还有一个 jquery UIBlocker,以防止用户在弹出页面处理完成之前返回页面。以下是关键代码:
父页面:
function parentFunc(a) {
// Unblocks on return from popup page.
$.unblockUI({});
document.getElementById("<%=Textbox1.ClientID %>").value = a;
alert("Please complete the update by entering a Brief Description then clicking the UPDATE link!!");
}
function parentCancel(s) {
// Unblocks because of cancel from popup page.
// var a = 0;
$.unblockUI({});
alert("Please click the Cancel link to complete the Cancel process!!");
}
PARENT PAGE Code Behind , Row Updatinfg 事件在构建字符串数组后传递到 POPUP 页面。
' Sets up popup to open when row selected for edit is cycled.
If IsPostBack Then
If (e.Row.RowState And DataControlRowState.Edit) > 0 Then
If Session("updateComplete") <> "Y" And Session("CancelUpdate") <> "Y" Then
Dim BrowserSettings As String = "status=no,toolbar=no, scrollbars =yes,menubar=no,location=no,resizable=no," & "titlebar=no, addressbar=no, width=850, height=800"
Dim URL As String = "NewpttStringPopUp.aspx"
Dim dialog As String = URL
Dim scriptText1 As String = ("<script>javascript: var w = window.open('" & URL & "','_blank','" & BrowserSettings & "'); $.blockUI({ message: '<h1>Please translate text and click Submit...</h1>' }); </script>")
ScriptManager.RegisterStartupScript(Me, GetType(Page), "ClientScript1", scriptText1, False)
Session("updateComplete") = "N"
End If
End If
End If
弹出页面:
function closeform() {
alert("Please click the Cancel Button at the buttom of the page to Cancel the process!!");
return "Please click the Cancel Button at the buttom of the page to Cancel the process!!";
}
function handleWindowClose() {
if ((window.event.clientX < 0) || (window.event.clientY < 0)) {
event.returnValue = "If you have made any changes to the fields without clicking the Save button, your changes will be lost.";
}
}
function callParentFunc()
{
var w = window.opener;
var a;
if (!w.closed) {
var val = w.parentFunc(a);
self.close();
}
this.window.focus()
}
function callParentCancel() {
var w = window.opener;
var s;
if (!w.closed) {
var val = w.parentCancel(s);
self.close();
}
}
CANCEL BUTTON 后面的 POPUP.ASPX.VB 代码
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
' Cancel Button so that no update is processed.
' Sets flag to prevent java popup from reopening after RowUpdating event. Occurs in RowDataBound event.
'Dim s As String = "c"
Dim strScript2 As String = "callParentCancel();"
ClientScript.RegisterStartupScript(GetType(Page), "callParentCancel", strScript2.ToString, True)
Session("UpdateEnd") = "Y"
Session("CancelUpdate") = "Y"
'Response.Write("<script>window.close();</script>")
End Sub
SUBMIT BUTTON 后面的 POPUP.ASPX.VB 代码
为简洁起见,不显示构建阵列的过程。
Session("returnTranslation") = arReturn
' Page.PreviousPage.Focus()
Dim strScript As String = "callParentFunc();"
ClientScript.RegisterStartupScript(GetType(Page), "callParentFunc", strScript.ToString, True)
' Sets flag to prevent java popup from reopening after RowUpdating event. Occurs in RowDataBound event.
Session("updateComplete") = "Y"
阻止弹出窗口重新加载时出现问题。所以在加载事件中有一个 if 条件。动态数量的控件作为文字构建在弹出窗口上。因此,Page Init 事件和 Page Load 事件在非 Postback 上触发以重建控件。
谢谢,所有的建议都会被审核。