あるページから別のページに値を渡そうとしますが、実行時に例外が発生します。あるページから別のページにパラメータを渡そうとしている間にNullReferenceExceptionを取得しています
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
Enter a value to post:
<asp:textbox id="TextBox1"
runat="Server">
</asp:textbox>
<br /><br />
<asp:button id="Button1"
text="Post back to this page"
runat="Server">
</asp:button>
<br /><br />
<asp:button id="Button2"
text="Post value to another page"
postbackurl="Button.PostBackUrlPage2cs.aspx"
runat="Server">
</asp:button>
</asp:Content>
はここで先のページにコードビハインドです::
は、ここに私のASPコードである
例外の詳細:システム
void Page_Load(object sender, System.EventArgs e) { string text; // Get the value of TextBox1 from the page that // posted to this page. text = ((TextBox)PreviousPage.FindControl("TextBox1")).Text; // Check for an empty string. if (text != "") PostedLabel.Text = "The string posted from the previous page is " + text + "."; else PostedLabel.Text = "An empty string was posted from the previous page."; }
私はこの例外を取得します。 NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていません。
私はmsdnから例を取った。
なぜこの例外が発生しますか? 、あなたはのUpdatePanel内でこれを持っていると仮定し
ですどの行にNullReferenceExceptionがありますか? –