0

リクエストを使用して、ネストされたページでフォーム コントロールの値 (テスト) を取得する必要があります。

私のHTMLファイル

<asp:Content ID="Content1" ContentPlaceHolderID="CPHText" runat="server">
    <asp:HiddenField ID="test" runat="server" />
</asp:Content>

コードビハインド

Public Sub RegisterNew(id As Guid) Implements testInterface
    test.Value = id.ToString()
End Sub

Public ReadOnly Property IsInitProp As Boolean Implements testInterface
    Get
        Return Not Request("test") = String.Empty
    End Get
End Property

を使用しRegisterNew()て、テストフィールドに値を割り当てます。IsInitPropプロパティで値を取得しようとすると、値を割り当てた後、 と表示されますNothing

しかし、以下のように通常のページ (ネストされたページではない) を使用すると、これは正しく機能します。

<form id="form1" runat="server">
    <asp:HiddenField ID="test" runat="server" />
</form>

ネストされたページでこの隠しフィールド値を取得するにはどうすればよいですか?

4

1 に答える 1

1

Me次のように、ID でページ オブジェクト ( ) を介してサーバー コントロールを参照するだけです。

Public ReadOnly Property IsInitProp As Boolean Implements testInterface
    Get
        Return Not Me.test.Value = String.Empty
    End Get
End Property
于 2013-10-16T11:47:31.657 に答える