Sempre non capendo a che serva
ho questo esempio fatto adesso: vedi se va bene
pagina A
codice:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="a.aspx.vb" Inherits="prove_a" %>
<!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>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<div id="div1" runat="server" style="border:1px blue solid">
<asp:Label ID="Label1" runat="server" BorderColor="Red" BorderStyle="Solid" BorderWidth="1px" Text="Pietro"></asp:Label>
<span>Prova</span>
</div>
</form>
</body>
</html>
codice pagina A
codice:
Option Strict On
Partial Class prove_a
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Session.Add("div", Me.div1)
Me.Response.Redirect("b.aspx")
End Sub
End Class
pagina B
codice:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="b.aspx.vb" Inherits="prove_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>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server">
<div id="div1" runat="server">xxxxxx</div>
</form>
</body>
</html>
codice pagina B
codice:
Option Strict On
Partial Class prove_b
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dv As System.Web.UI.HtmlControls.HtmlGenericControl = DirectCast(Me.Session("div"), System.Web.UI.HtmlControls.HtmlGenericControl)
Me.div1.Parent.Controls.Add(dv)
Me.div1.Parent.Controls.Remove(Me.div1)
End Sub
End Class