【ASP.NET】値の受け渡し

GETメソッドの値を取得

Dim name As String = Request.QueryString("Name"); 

サンプル

【送信元:WebForm1.aspx】

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Response.Redirect("WebForm2.aspx?Name=" & TextBox1.Text)
End Sub

送信先:WebForm2.aspx】

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim name As String = Request.QueryString("Name")
    Me.Label1.Text = "Hello, " & name & "!"
End Sub

参考文献

http://www.atmarkit.co.jp/fdotnet/vblab/aspnetforvb04/aspnetforvb04_02.html

POSTメソッドの値を取得

Dim remarks As String = Request.Form("Remarks"); 

子ウィンドウへのデータの受け渡し

 * JavaScriptを併用する

サンプル

【送信元:WebForm1.aspx】

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim script As New System.Text.StringBuilder()
    script.Append("ret = window.showModalDialog('WebForm2.aspx?SelectDate=' + " & TextBox2.ClientID & ".value,'', 'dialogWidth:200px;dialogHeight:350px;');")
    script.Append(TextBox2.ClientID & ".value=ret;")
    script.Append("return false;")
    Button2.Attributes("onclick") = script.ToString()
End Sub

送信先:WebForm2.aspx】

[プログラム部]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Calendar1.SelectedDate = Date.Parse(Request.QueryString("SelectDate"))
    Calendar1.VisibleDate = Calendar1.SelectedDate
    TextBox1.Text = Request.QueryString("SelectDate")

    Dim script As New System.Text.StringBuilder()
    script.Append("window.returnValue = " & TextBox1.ClientID & ".value;")
    script.Append("window.close();")
    Button1.Attributes("onclick") = script.ToString()
End Sub

Protected Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar1.SelectionChanged
    TextBox1.Text = Calendar1.SelectedDate.ToShortDateString()
End Sub
[デザイン部]
<head runat="server">
    <base target="_self">
    <title></title>
</head>

関連記事

クッキー(Cookie

http://blogs.yahoo.co.jp/dk521123/28439642.html

ViewState

http://blogs.yahoo.co.jp/dk521123/27605311.html

セッション(Session)

http://blogs.yahoo.co.jp/dk521123/28490495.html

アプリケーション状態管理(Applicationオブジェクト)

http://blogs.yahoo.co.jp/dk521123/27476083.html

値の受け渡し

http://blogs.yahoo.co.jp/dk521123/28449946.html