紧急求助:使用母版页的页面参数传递的方法
时间:2011-12-09
来源:互联网
测试环境:ASP.NET 程序语言:VB.NET
a.aspx:使用母版页的页面
b.aspx:普通Web页面
a页面中的textbox1文本框输入0后,弹出b页面
b页面上有一个label1标签控件和一个button控件,点击按钮控件关闭b页面,并将标签控件文本传递回a页面,然后更新a页面的textbox1控件值为b页面的label1控件值
经测试目前存在的问题有:
1、IE6中测试:如两个页面为普通WEB页面,测试正常,回传参数值准确;如主页面为使用母版页的WEB页面则测试无反应,参数不能传递回主页面
2、IE9下测试,页面代码报错:Microsoft JScript 运行时错误: 无法设置属性“value”的值: 对象为 null 或未定义
请各位帮助解决,谢谢!
母版页代码:Site1.Master
HTML code
a.aspx页面代码:
HTML code
b.aspx页面代码:
HTML code
a.aspx后台程序代码:
VB.NET code
b.aspx后台程序代码:
VB.NET code
a.aspx:使用母版页的页面
b.aspx:普通Web页面
a页面中的textbox1文本框输入0后,弹出b页面
b页面上有一个label1标签控件和一个button控件,点击按钮控件关闭b页面,并将标签控件文本传递回a页面,然后更新a页面的textbox1控件值为b页面的label1控件值
经测试目前存在的问题有:
1、IE6中测试:如两个页面为普通WEB页面,测试正常,回传参数值准确;如主页面为使用母版页的WEB页面则测试无反应,参数不能传递回主页面
2、IE9下测试,页面代码报错:Microsoft JScript 运行时错误: 无法设置属性“value”的值: 对象为 null 或未定义
请各位帮助解决,谢谢!
母版页代码:Site1.Master
HTML code
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site1.master.vb" Inherits="WebApplication2.Site1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div>母版页 <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form> </body> </html>
a.aspx页面代码:
HTML code
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="a.aspx.vb" Inherits="WebApplication2.a" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox> </asp:Content>
b.aspx页面代码:
HTML code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="b.aspx.vb" Inherits="WebApplication2.b" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="9999"></asp:Label> <asp:Button ID="Button1" runat="server" Text="传递参数" /> </div> </form> </body> </html>
a.aspx后台程序代码:
VB.NET code
Public Class a Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged If TextBox1.Text = "0" Then Response.Write(" <script> window.open( 'b.aspx','参数窗口', 'height=200, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no'); </script> ") End Sub End Class
b.aspx后台程序代码:
VB.NET code
Public Class b Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Dim scriptstr As String scriptstr = " <script> window.opener.document.getElementById('textbox1').value= '" & Label1.Text & " '; " & " </script> " Page.ClientScript.RegisterStartupScript(Me.GetType(), "return ", scriptstr) Page.ClientScript.RegisterStartupScript(Me.GetType(), "close ", " <script> top.opener=null;top.close(); </script> ") End Sub End Class
作者: lovechate 发布时间: 2011-12-09

作者: sotom 发布时间: 2011-12-09
这哥们帖是不是发错地方了
作者: MrsFeng 发布时间: 2011-12-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28