开发者

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

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("/Rac开发者_如何学CkRecable.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


I think that's because the textbox is readonly. Remove the readonly property before applying the text, then put it back afterwards.


I fixed this by placing the textbox inside of the Panel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜