wazodnuit
wazodnuit

Reputation: 3

Pass TextBox input to variable in ContentPlaceHolder

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.

Upvotes: 0

Views: 192

Answers (2)

wazodnuit
wazodnuit

Reputation: 3

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

Upvotes: 0

Md. Mehedi Hassan
Md. Mehedi Hassan

Reputation: 27

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

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

Upvotes: 0

Related Questions