0
votes

I can easily pass the textbox input to a variable in an HTML form, but things don't work when using a master page and ContentPlaceHolder.

My Master page is "Site.Master" My sister page is "Page1.aspx"

In it I have asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" Runat="Server", with textBox1.

How to get that input ?

  protected void Button1_Click(object sender, EventArgs e)
{

        string MyContent = TextBox1.Text;
}

This action returns the original text of TextBox1 but not what the user input.

2

2 Answers

0
votes

Please check your Textbox has runat="server" property like

<asp:textbox id="txtName" runat="server"/>
0
votes

Ahh, of course... I forgot the "if (!Page.IsPostBack)" in Page_Load.