Can't write text into textbox in ASP.NET web app

Posted by dotnetdev on Stack Overflow See other posts from Stack Overflow or by dotnetdev
Published on 2010-05-19T09:38:14Z Indexed on 2010/05/19 9:40 UTC
Read the original article Hit count: 256

Filed under:

Hi,

I have an ASP.NET web application.

In the codebehind for the .ascx page (which I embed as below), I attempt to write a string to a textbox in a method like this:

Code for embedding control:

Control ctrl = Page.LoadControl("/RackRecable.ascx"); PlaceHolder1.Controls.Add(ctrl);

Method to make string for inserting into textbox:

   string AppendDetails()
    {
        StringBuilder sb = new StringBuilder();

        sb.Append("msg" + "    " + textbox1.Text etc etc );


        return sb.ToString();
    }

Called as (in codebehind event handler for button click):

            this.TextBox4.Text = AppendDetails();

I call it by using ATextBox.Text = AppendDetails (in the button click event handler). The textbox TextBox4 is in the designer file so I am confused why the text does not get written into this textbox (it is readonly and enabled).

When stepping through, the textbox4 control will successfully show the text I want it to display in quick watch but not in the actual page, it won't.

Any ideas?

Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET