I'm really struggling with this. The problem is only with the content pages.
I am trying to access a Text Box value from one content page ("Page1.aspx") in another content page ("Page2.aspx"). I'm not sure whether it is relevant that they are the children of nested master pages, but I thought I'd throw it in.
Page1.aspx is a basic form with text boxes and a submit button. The text box in Page1.aspx is called "tbFirst". The submit button has the following code:
<asp:Button ID="Button1" runat="server" Text="New Member Form" PostBackUrl="Page2.aspx"/>
Page2.aspx is a new form which should be populated with a textbox value from the previous page.
The second line show <%@ PreviousPageType VirtualPath="~/Page1.aspx" %>
For testing purposes I am using a label ("lblResult") to display my results.
Codebehind looks like this:
if (PreviousPage != null)
{
TextBox SourceTextBox =
(TextBox)PreviousPage.FindControl("tbFirst");
if (SourceTextBox != null)
{
lblResult.Text = SourceTextBox.Text;
}
else
{
lblResult.Text = "No text found";
}
}
else
{
lblResult.Text = "No Control found";
}
}
}
The problem is that the label text in Page2.aspx says "No text found".
I think that's all the relevant info. Anyone got any ideas? I've spent the whole afternoon trawling the forums and nothing I've tried works.