0

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 Answers 2

0

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

<asp:textbox id="txtName" runat="server"/>
Sign up to request clarification or add additional context in comments.

1 Comment

It's in there. I edited my post to add part of code.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.