How to settext to HtmlTextAreaElement

Last post 10-15-2009 8:21 PM by farmas. 7 replies.

Sort Posts:

  • How to settext to HtmlTextAreaElement

    10-06-2009, 10:03 AM
    • Member
      5 point Member
    • david4chao
    • Member since 08-19-2009, 12:47 PM
    • Posts 6


    I have an HtmlTextAreaElement which I want to set text.

                HtmlTextAreaElement _ControlOfsummary = (HtmlTextAreaElement)_ContainerOfControlOfsummary.ChildElements.Find("ControlID_Prefix_Editor_FreeTextBox_summary");
                _ControlOfsummary.SetText("Test string 111111111111111");

    HtmlTextAreaElement _ControlOfsummary = (HtmlTextAreaElement)_ContainerOfControlOfsummary.ChildElements.Find("summary");

    _ControlOfsummary.SetText("Test string");


    It is not working.



    Filed under:
  • Re: How to settext to HtmlTextAreaElement

    10-07-2009, 12:05 AM
    • Contributor
      4,983 point Contributor
    • karthicks
    • Member since 01-09-2009, 12:43 PM
    • Chennai
    • Posts 858

    in server you can do like  this.TextArea1.Value = "text"; ( to access this control @ server-side it should have runat="server")

    in client-side - document.getElementById('TextArea1').value='text';

    If this post is useful,
    Please,Dont Forget to click Mark As Answer and Earn Your Point

    Thanks,
    Karthick S
    Celebrate Programming
  • Re: How to settext to HtmlTextAreaElement

    10-07-2009, 1:23 AM
    • Participant
      1,114 point Participant
    • farmas
    • Member since 08-05-2002, 8:19 AM
    • Redmond, WA
    • Posts 249
    • AspNetTeam

    Interesting. I will try to repro this tomorrow and let you know what I find.

    - Federico

  • Re: How to settext to HtmlTextAreaElement

    10-07-2009, 9:55 AM
    • Member
      5 point Member
    • david4chao
    • Member since 08-19-2009, 12:47 PM
    • Posts 6

    karthicks:

    in server you can do like  this.TextArea1.Value = "text"; ( to access this control @ server-side it should have runat="server")

    in client-side - document.getElementById('TextArea1').value='text';


    Can you try Asp.Net QA api?

    Thanks.

    Filed under:
  • Re: How to settext to HtmlTextAreaElement

    10-09-2009, 1:25 AM
    • Participant
      1,114 point Participant
    • farmas
    • Member since 08-05-2002, 8:19 AM
    • Redmond, WA
    • Posts 249
    • AspNetTeam

    I tried this in the office today but I could not get to repro the problem.

    I have a page with <textarea id="textarea"></textarea> and my test looks like this:

    [WebTestMethod]
        public void TypeOnATextArea()
        {
            HtmlPage page = new HtmlPage("Login.aspx");

            page.Elements.Find("textarea").SetText("foobar");
        }


    After running in FireFox I see the text in there. If you are still seeing this problem, could you provide some more details?

    - Federico

  • Re: How to settext to HtmlTextAreaElement

    10-14-2009, 3:03 AM
    • Participant
      908 point Participant
    • osbornm
    • Member since 09-01-2006, 9:15 PM
    • Redmond, WA
    • Posts 193
    • AspNetTeam
      Moderator

    I am unable to repro this issue aswell... Can you post a repro please

     

    Matthew M. Osborn
    http://blog.osbornm.com
    http://www.codingqa.com
    http://weblogs.asp.net/asptest
    "Change the world or go home."
  • Re: How to settext to HtmlTextAreaElement

    10-14-2009, 12:14 PM
    Answer
    • Member
      5 point Member
    • david4chao
    • Member since 08-19-2009, 12:47 PM
    • Posts 6

    david4chao:


    I have an HtmlTextAreaElement which I want to set text.

     

                HtmlTextAreaElement _ControlOfsummary = (HtmlTextAreaElement)_ContainerOfControlOfsummary.ChildElements.Find("ControlID_Prefix_Editor_FreeTextBox_summary");
                _ControlOfsummary.SetText("Test string 111111111111111");

    HtmlTextAreaElement _ControlOfsummary = (HtmlTextAreaElement)_ContainerOfControlOfsummary.ChildElements.Find("summary");

    _ControlOfsummary.SetText("Test string");


    It is not working.

     

     

    When switch between EditItemTemplate and ItemTemplate of GridView, sometimes, cannot set to the TextArea.

    Refrshing parent HtmlElement will solve the problem.

    Filed under:
  • Re: How to settext to HtmlTextAreaElement

    10-15-2009, 8:21 PM
    Answer
    • Participant
      1,114 point Participant
    • farmas
    • Member since 08-05-2002, 8:19 AM
    • Redmond, WA
    • Posts 249
    • AspNetTeam

    I see, your last message hints that the problem is that the in memory DOM that LTAF works against was not updated between different renderings of the control.

    This is by design, since there is no way for LTAF to know that it should go a retrieve the DOM again, that is why it works when you refresh the element (which tells LTAF to go and grab the latest DOM from the browser).

    - Federico 

Page 1 of 1 (8 items)