I have a multiline textbox on my form. It is filled on load with content from a database. The user then manipulates this data, and it needs to be updated on the database. I have everything working except for getting the changed value of the textbox.

In the on_click event i try to get the value of the textbox like:

variable = txtbxName.Text;

when I do this it returns only the value it was pre-loaded with and not the value with the user updates.

I have tried setting autopostback to true and tried to databind() the controls, neither of these is the solution to my problem. I think I am missing a key piece of information, please help (c# native if possible).

Dani AI

Generated

Short answer: either the browser never posted the changed text or your server-side code is overwriting it after the postback. Since already guards the initial fill with an IsPostBack check, the next likely causes are a later DataBind/reassignment, a disabled input, or a client-side editor/script not updating the actual textarea.

Troubleshooting checklist (fast, sequential):

  • Put a breakpoint in the submit handler and compare txtBxContent.Text with the raw form value to tell whether the browser sent the change at all.
  • Search the codebase for any DataBind() calls or places that set the TextBox.Text outside the initial-load guard — these will overwrite user input. Also check master pages, user controls and PreRender events.
  • Inspect the rendered HTML (View Source / DevTools): if the textarea is disabled it will not be posted; readonly will be posted. If you use client-side code or a WYSIWYG editor, ensure it writes back into the textarea (many editors require an explicit save/trigger before submit).

If you want to read exactly what the browser posted (bypassing control state) use Request.Form with the control UniqueID:

string posted = Request.Form[txtBxContent.UniqueID];

If posted contains the updated text but txtBxContent.Text does not, something in the page lifecycle is reassigning the control after post-data is loaded. If posted is empty or unchanged, the problem is client-side (disabled field, wrong element updated, or editor not syncing).

Note: was right to look at state-related issues, but ViewState itself is not how the browser sends user edits — posted form data is. The hidden-field trick or explicitly syncing your client editor to the textarea can be a reliable fallback when client scripts replace the native textarea.

Recommended Answers

All 3 Replies

I really feel like i'm missing something here... Here's what I have

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string qryString = Request.QueryString["id"];

                fillContents(qryString);
            }
        }

so i fetch my querystring and use my method which fills my textbox.
Then...

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string title = txtBxTitle.Text;
            string content = txtBxContent.Text.Replace(Environment.NewLine, "<br />");
...more fun stuff
        }

at this point, im expecting content and title to be filled with the current value of boxes, yet it still gives me the original filled value. I'm going nuts, please help...

This is 32nd Post of thacravedawg. The sun isn't up yet - Wake up and format the code

I really feel like i'm missing something here... Here's what I have

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string qryString = Request.QueryString["id"];
                fillContents(qryString);
            }
        }

so i fetch my querystring and use my method which fills my textbox.
Then...

protected void btnSubmit_Click(object sender, EventArgs e)
 {
     string title = txtBxTitle.Text;
    string content = txtBxContent.Text.Replace  (Environment.NewLine, "<br />");
...more fun stuff
  }

at this point, im expecting content and title to be filled with the current value of boxes, yet it still gives me the original filled value. I'm going nuts, please help...

ViewState may be causing the problem. If this continues to occur, consider placing hidden input control and copy the value of the textbox to that hidden upon the page posting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.