这是一张用 javascript 弹出的页面,我在 page_load 中写了下面的代码,由于页中有其它的操作,因此,会有N次 符合 postback 的操作,但我希望在点击 sure 按钮的时候,先执行getcheck()
If ReturnStr.Split(",").Length > 2 Then
Msg("接收人只能选择一个")
Exit Sub
End If这段代码,然后再运行下面 strscript 中的 Return_Val() 函数.我在网上看到的都是在第一次符合 postback 的时候就退出,但我现在是有多次 postback, 请问如何解决?//下面是 弹出式页面中 page_load 中的代码.
If Not IsPostBack Then
MyBody.Attributes.Add("onload", "document.frmMain.TextBox1.value=window.parent.dialogArguments")
Sure.Visible = False
dgMain.Visible = False
Label2.Visible = False
RefreshGrid(0)
Else GetChecked() If ReturnStr.Split(",").Length > 2 Then
Msg("接收人只能选择一个")
Exit Sub
End If ImageButton6.Attributes.Add("onclick", "OpenSearch()")
Sure.Attributes.Add("onclick", "Return_Val()") Dim strScript As String = "<script>" + vbCrLf
strScript += "function Return_Val(){" + vbCrLf
strScript += "window.parent.returnValue='" + Trim(ReturnStr.Split(",").GetValue(0)) + "'" + vbCrLf
strScript += "window.parent.close()" + vbCrLf
strScript += "}" + vbCrLf
strScript += "</script>" + vbCrLf strScript += "<script>" + vbCrLf
strScript += "function OpenSearch(){" + vbCrLf
strScript += "var str=window.showModalDialog('ProjectFm.aspx',document.frmMain.SearchStr.value,'dialogWidth:600px;')" + vbCrLf strScript += "if(str!=null) document.frmMain.SearchStr.value=str" + vbCrLf
strScript += "}" + vbCrLf
strScript += "</script>" + vbCrLf If (Not IsClientScriptBlockRegistered("clientScript")) Then
RegisterClientScriptBlock("clientScript", strScript)
End IfEnd If
If ReturnStr.Split(",").Length > 2 Then
Msg("接收人只能选择一个")
Exit Sub
End If这段代码,然后再运行下面 strscript 中的 Return_Val() 函数.我在网上看到的都是在第一次符合 postback 的时候就退出,但我现在是有多次 postback, 请问如何解决?//下面是 弹出式页面中 page_load 中的代码.
If Not IsPostBack Then
MyBody.Attributes.Add("onload", "document.frmMain.TextBox1.value=window.parent.dialogArguments")
Sure.Visible = False
dgMain.Visible = False
Label2.Visible = False
RefreshGrid(0)
Else GetChecked() If ReturnStr.Split(",").Length > 2 Then
Msg("接收人只能选择一个")
Exit Sub
End If ImageButton6.Attributes.Add("onclick", "OpenSearch()")
Sure.Attributes.Add("onclick", "Return_Val()") Dim strScript As String = "<script>" + vbCrLf
strScript += "function Return_Val(){" + vbCrLf
strScript += "window.parent.returnValue='" + Trim(ReturnStr.Split(",").GetValue(0)) + "'" + vbCrLf
strScript += "window.parent.close()" + vbCrLf
strScript += "}" + vbCrLf
strScript += "</script>" + vbCrLf strScript += "<script>" + vbCrLf
strScript += "function OpenSearch(){" + vbCrLf
strScript += "var str=window.showModalDialog('ProjectFm.aspx',document.frmMain.SearchStr.value,'dialogWidth:600px;')" + vbCrLf strScript += "if(str!=null) document.frmMain.SearchStr.value=str" + vbCrLf
strScript += "}" + vbCrLf
strScript += "</script>" + vbCrLf If (Not IsClientScriptBlockRegistered("clientScript")) Then
RegisterClientScriptBlock("clientScript", strScript)
End IfEnd If
虽然ajax现在是毁誉参半,但是对于页面的局部刷新和异步执行做的还是不错的.