Asp.net 实现弹窗打开子窗口并通过Session传值

弹窗打开新窗口。
母窗口放置【弹窗】按钮,点击【弹窗】按钮,向Session中储存值,并打开子窗口。
子窗口中通过标签显示Session中的值。另外在子窗口中放置【选择】按钮,点击【选择】按钮,向Session中储存值,并向母窗口Submit。
母窗口PostBack,页面装载时,取得Session中的值,显示在TextBox中。

●母窗口aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 

 

 
 
母窗口画面 
 
 
    

●母窗口aspx.vb

Partial Class _Default 
    Inherits System.Web.UI.Page 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
        If IsPostBack Then 
            Me.TextBox1.Text = CStr(Session("ITEM")) 
        End If 
    End Sub 

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
        Session("KEY") = "AAA" 

        Dim scriptStr As String 
        scriptStr = "" 

        ClientScript.RegisterStartupScript(Me.GetType(), "Default2画面", scriptStr) 
    End Sub 
End Class 

●子窗口aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %> 

 

 
 
    子窗口画面 
 
 
    

●子窗口aspx.vb

Partial Class Default2 
    Inherits System.Web.UI.Page 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
        Me.Label1.Text = CStr(Session("KEY")) 
End Sub 

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
        Session("ITEM") = "BBB" 

        Dim scriptStr As String 
        scriptStr = "" 

        ClientScript.RegisterStartupScript(Me.GetType(), "Default2画面", scriptStr) 

    End Sub 
End Class 

原文链接:http://www.cocoaliz.com/asp.net/index.php/68/

你可能感兴趣的:(Asp.net 实现弹窗打开子窗口并通过Session传值)