Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. TextArea value in C#

TextArea value in C#

Scheduled Pinned Locked Moved ASP.NET
csharphtmlsysadminquestion
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vanikanc
    wrote on last edited by
    #1

    Hi, I have an HTML element defined as :

    <textarea id="txtOrdersNotResult" runat="server" rows="5" cols="15" visible="false"></textarea>

    when certain condition hold true, it triggers the textarea to be visible. Then it should set a value in this area, like

    txtOrdersNotResult.Value = "this is a test"

    I have also tried,

    txtOrdersNotResult.InnerText = doesnotexist.ToString();

    this area is empty. any ideas?

    S A 2 Replies Last reply
    0
    • V vanikanc

      Hi, I have an HTML element defined as :

      <textarea id="txtOrdersNotResult" runat="server" rows="5" cols="15" visible="false"></textarea>

      when certain condition hold true, it triggers the textarea to be visible. Then it should set a value in this area, like

      txtOrdersNotResult.Value = "this is a test"

      I have also tried,

      txtOrdersNotResult.InnerText = doesnotexist.ToString();

      this area is empty. any ideas?

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      You shared your requirement and not the issue you are facing while implementing it. Now 2 things: 1. Don't use visible attribute. It will not even render the control and thus will not be accessible through JavaScript. Use style attribute 'display' style="display:none", set it to display:block to show. 2. to set the value in it, use attribute value (starts with small V)

      txtOrdersNotResult.value = "this is a test"

      Hope both the tips should be enough for you to implement it.

      Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

      A 1 Reply Last reply
      0
      • V vanikanc

        Hi, I have an HTML element defined as :

        <textarea id="txtOrdersNotResult" runat="server" rows="5" cols="15" visible="false"></textarea>

        when certain condition hold true, it triggers the textarea to be visible. Then it should set a value in this area, like

        txtOrdersNotResult.Value = "this is a test"

        I have also tried,

        txtOrdersNotResult.InnerText = doesnotexist.ToString();

        this area is empty. any ideas?

        A Offline
        A Offline
        Ali Al Omairi Abu AlHassan
        wrote on last edited by
        #3

        Sir; You said:

        when certain condition hold true, it triggers the textarea to be visible.

        Please elaborate or show me your code.

        Help people,so poeple can help you.

        V 1 Reply Last reply
        0
        • S Sandeep Mewara

          You shared your requirement and not the issue you are facing while implementing it. Now 2 things: 1. Don't use visible attribute. It will not even render the control and thus will not be accessible through JavaScript. Use style attribute 'display' style="display:none", set it to display:block to show. 2. to set the value in it, use attribute value (starts with small V)

          txtOrdersNotResult.value = "this is a test"

          Hope both the tips should be enough for you to implement it.

          Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

          A Offline
          A Offline
          Ali Al Omairi Abu AlHassan
          wrote on last edited by
          #4

          I don't think he's talking about javascript, does he?

          Help people,so poeple can help you.

          S 1 Reply Last reply
          0
          • A Ali Al Omairi Abu AlHassan

            I don't think he's talking about javascript, does he?

            Help people,so poeple can help you.

            S Offline
            S Offline
            Sandeep Mewara
            wrote on last edited by
            #5

            Ali Al Omairi(Abu AlHassan) wrote:

            he's talking about javascript, does he?

            Yes, he is. See the reference of InnerText (which clearly tells it's JS)

            Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

            A 1 Reply Last reply
            0
            • S Sandeep Mewara

              Ali Al Omairi(Abu AlHassan) wrote:

              he's talking about javascript, does he?

              Yes, he is. See the reference of InnerText (which clearly tells it's JS)

              Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

              A Offline
              A Offline
              Ali Al Omairi Abu AlHassan
              wrote on last edited by
              #6

              Couldn't be a property in HTMLGenericControl class?

              Help people,so poeple can help you.

              S 1 Reply Last reply
              0
              • A Ali Al Omairi Abu AlHassan

                Couldn't be a property in HTMLGenericControl class?

                Help people,so poeple can help you.

                S Offline
                S Offline
                Sandeep Mewara
                wrote on last edited by
                #7

                Yep. :thumbsup:

                Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

                1 Reply Last reply
                0
                • A Ali Al Omairi Abu AlHassan

                  Sir; You said:

                  when certain condition hold true, it triggers the textarea to be visible.

                  Please elaborate or show me your code.

                  Help people,so poeple can help you.

                  V Offline
                  V Offline
                  vanikanc
                  wrote on last edited by
                  #8

                  Thank you for all your help! This web application is written in C#, I should have specified that. So, the small and big "V" would not have been an issue. Also, "InnerText" is a property of of the textarea. Not Javascript. Solved this problem by using an asp:Literal tag. Thank you!

                  A 1 Reply Last reply
                  0
                  • V vanikanc

                    Thank you for all your help! This web application is written in C#, I should have specified that. So, the small and big "V" would not have been an issue. Also, "InnerText" is a property of of the textarea. Not Javascript. Solved this problem by using an asp:Literal tag. Thank you!

                    A Offline
                    A Offline
                    Ali Al Omairi Abu AlHassan
                    wrote on last edited by
                    #9

                    so, your problem was that the tag

                    <textarea id="TextBox1" runat="server" ></textarea>

                    generates an object of type HTMLGenericControl. when the page is first loaded, the server want mention the control in the response if TextBox1.Visible is set to false, nor in the viewstate. So, when the TextBox1.Visible is set again to true on the button click request the server wont load TextBox1's properties of TextBox1 from the request so they need to be set again.

                    Help people,so poeple can help you.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups