changing value of html control from c# code in asp.net website

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • saurabh

    changing value of html control from c# code in asp.net website

    Can anybody tell me how to change the value of an html control from the
    c#....
    eg i hv one asp.net radio button control and one html hidden
    variable...
    so on page load in case the radio button is checked i want to set this
    hidden variable to 1 else 0...

    I am not getting what to write in Page_Load(objec t sender,
    System.EventArg s e) function to change the value of this html
    variable...

  • saurabh

    #2
    Re: changing value of html control from c# code in asp.net website

    hey pls reply if u hv any idea...its kindaa urgent...


    saurabh wrote:
    Can anybody tell me how to change the value of an html control from the
    c#....
    eg i hv one asp.net radio button control and one html hidden
    variable...
    so on page load in case the radio button is checked i want to set this
    hidden variable to 1 else 0...
    >
    I am not getting what to write in Page_Load(objec t sender,
    System.EventArg s e) function to change the value of this html
    variable...

    Comment

    • Sean

      #3
      RE: changing value of html control from c# code in asp.net website

      I think it might be easier just to use a server control becuase otherwise for
      the most part the server doesnt even know it exists.
      Depending on your needs that might be the best solution.

      even if you went the route of having the server re-create the html control
      on each load/postback it would take as much server "power" as it would to
      just use a server control

      "saurabh" wrote:
      Can anybody tell me how to change the value of an html control from the
      c#....
      eg i hv one asp.net radio button control and one html hidden
      variable...
      so on page load in case the radio button is checked i want to set this
      hidden variable to 1 else 0...
      >
      I am not getting what to write in Page_Load(objec t sender,
      System.EventArg s e) function to change the value of this html
      variable...
      >
      >

      Comment

      • saurabh

        #4
        Re: changing value of html control from c# code in asp.net website


        as per requirments this might not be possible in my case....Does any
        body has idea at any one of the following:
        1) To check if a server control radiobutton checked or not , using the
        javascript, each time page is loaded....If u know tell me wht all steps
        need to be taken.
        2) or to change the value of a hidden html variable from inside the c#
        code that we write in asp.net website....
        -----------------

        Sean wrote:
        I think it might be easier just to use a server control becuase otherwise for
        the most part the server doesnt even know it exists.
        Depending on your needs that might be the best solution.
        >
        even if you went the route of having the server re-create the html control
        on each load/postback it would take as much server "power" as it would to
        just use a server control
        >
        "saurabh" wrote:
        >
        Can anybody tell me how to change the value of an html control from the
        c#....
        eg i hv one asp.net radio button control and one html hidden
        variable...
        so on page load in case the radio button is checked i want to set this
        hidden variable to 1 else 0...

        I am not getting what to write in Page_Load(objec t sender,
        System.EventArg s e) function to change the value of this html
        variable...

        Comment

        • Sean

          #5
          Re: changing value of html control from c# code in asp.net website

          1. getting access to values of serverside controls using javascript is a
          subject that was lightly touched on in one of my books called "ASP.Net 2.0
          Advanced Application Design" and its labeled as "expert" content. Its also a
          very messy and long process from the best I can tell.
          If you set a server control autopostback = true then the second the user
          checks that checkbox your server side will know its been checked. That said
          autopostback makes a round trip to the server which is usually not an issue
          but sometimes its perfered the user doesnt see a refresh of the page unless
          they have to.
          2. I have no idea what you are talking about here. HTML variable?

          "saurabh" wrote:
          >
          as per requirments this might not be possible in my case....Does any
          body has idea at any one of the following:
          1) To check if a server control radiobutton checked or not , using the
          javascript, each time page is loaded....If u know tell me wht all steps
          need to be taken.
          2) or to change the value of a hidden html variable from inside the c#
          code that we write in asp.net website....
          -----------------
          >
          Sean wrote:
          I think it might be easier just to use a server control becuase otherwise for
          the most part the server doesnt even know it exists.
          Depending on your needs that might be the best solution.

          even if you went the route of having the server re-create the html control
          on each load/postback it would take as much server "power" as it would to
          just use a server control

          "saurabh" wrote:
          Can anybody tell me how to change the value of an html control from the
          c#....
          eg i hv one asp.net radio button control and one html hidden
          variable...
          so on page load in case the radio button is checked i want to set this
          hidden variable to 1 else 0...
          >
          I am not getting what to write in Page_Load(objec t sender,
          System.EventArg s e) function to change the value of this html
          variable...
          >
          >
          >
          >

          Comment

          • saurabh

            #6
            Re: changing value of html control from c# code in asp.net website

            by html variable i mean a hidden html variable or say a textbox....is
            thr any way to change the text of a text box from the c# code?? point
            it tht textbox is not a server control , so textbox.text="b lahblah"
            wont work...


            Sean wrote:
            1. getting access to values of serverside controls using javascript is a
            subject that was lightly touched on in one of my books called "ASP.Net 2.0
            Advanced Application Design" and its labeled as "expert" content. Its also a
            very messy and long process from the best I can tell.
            If you set a server control autopostback = true then the second the user
            checks that checkbox your server side will know its been checked. That said
            autopostback makes a round trip to the server which is usually not an issue
            but sometimes its perfered the user doesnt see a refresh of the page unless
            they have to.
            2. I have no idea what you are talking about here. HTML variable?
            >
            "saurabh" wrote:
            >

            as per requirments this might not be possible in my case....Does any
            body has idea at any one of the following:
            1) To check if a server control radiobutton checked or not , using the
            javascript, each time page is loaded....If u know tell me wht all steps
            need to be taken.
            2) or to change the value of a hidden html variable from inside the c#
            code that we write in asp.net website....
            -----------------

            Sean wrote:
            I think it might be easier just to use a server control becuase otherwise for
            the most part the server doesnt even know it exists.
            Depending on your needs that might be the best solution.
            >
            even if you went the route of having the server re-create the html control
            on each load/postback it would take as much server "power" as it would to
            just use a server control
            >
            "saurabh" wrote:
            >
            Can anybody tell me how to change the value of an html control from the
            c#....
            eg i hv one asp.net radio button control and one html hidden
            variable...
            so on page load in case the radio button is checked i want to set this
            hidden variable to 1 else 0...

            I am not getting what to write in Page_Load(objec t sender,
            System.EventArg s e) function to change the value of this html
            variable...

            Comment

            • Sean

              #7
              Re: changing value of html control from c# code in asp.net website

              just so i get an idea of your background do you know what viewstate is?

              This will help me no repeat information that you already know.

              "saurabh" wrote:
              >
              as per requirments this might not be possible in my case....Does any
              body has idea at any one of the following:
              1) To check if a server control radiobutton checked or not , using the
              javascript, each time page is loaded....If u know tell me wht all steps
              need to be taken.
              2) or to change the value of a hidden html variable from inside the c#
              code that we write in asp.net website....
              -----------------
              >
              Sean wrote:
              I think it might be easier just to use a server control becuase otherwise for
              the most part the server doesnt even know it exists.
              Depending on your needs that might be the best solution.

              even if you went the route of having the server re-create the html control
              on each load/postback it would take as much server "power" as it would to
              just use a server control

              "saurabh" wrote:
              Can anybody tell me how to change the value of an html control from the
              c#....
              eg i hv one asp.net radio button control and one html hidden
              variable...
              so on page load in case the radio button is checked i want to set this
              hidden variable to 1 else 0...
              >
              I am not getting what to write in Page_Load(objec t sender,
              System.EventArg s e) function to change the value of this html
              variable...
              >
              >
              >
              >

              Comment

              • Sean

                #8
                Re: changing value of html control from c# code in asp.net website

                I have used webserver controls and hidden them on the page for similar
                reasons however for a client side control all values are lost on each post to
                the server unless you keep the value in a cookie, viewstate, sessionstate etc.

                That is why I asked if you know what viewstate is. If you dont, then there
                is a bit of a learning curve on how to keep values in the web applications

                "saurabh" wrote:
                by html variable i mean a hidden html variable or say a textbox....is
                thr any way to change the text of a text box from the c# code?? point
                it tht textbox is not a server control , so textbox.text="b lahblah"
                wont work...
                >
                >
                Sean wrote:
                1. getting access to values of serverside controls using javascript is a
                subject that was lightly touched on in one of my books called "ASP.Net 2.0
                Advanced Application Design" and its labeled as "expert" content. Its also a
                very messy and long process from the best I can tell.
                If you set a server control autopostback = true then the second the user
                checks that checkbox your server side will know its been checked. That said
                autopostback makes a round trip to the server which is usually not an issue
                but sometimes its perfered the user doesnt see a refresh of the page unless
                they have to.
                2. I have no idea what you are talking about here. HTML variable?

                "saurabh" wrote:
                >
                as per requirments this might not be possible in my case....Does any
                body has idea at any one of the following:
                1) To check if a server control radiobutton checked or not , using the
                javascript, each time page is loaded....If u know tell me wht all steps
                need to be taken.
                2) or to change the value of a hidden html variable from inside the c#
                code that we write in asp.net website....
                -----------------
                >
                Sean wrote:
                I think it might be easier just to use a server control becuase otherwise for
                the most part the server doesnt even know it exists.
                Depending on your needs that might be the best solution.

                even if you went the route of having the server re-create the html control
                on each load/postback it would take as much server "power" as it would to
                just use a server control

                "saurabh" wrote:

                Can anybody tell me how to change the value of an html control from the
                c#....
                eg i hv one asp.net radio button control and one html hidden
                variable...
                so on page load in case the radio button is checked i want to set this
                hidden variable to 1 else 0...
                >
                I am not getting what to write in Page_Load(objec t sender,
                System.EventArg s e) function to change the value of this html
                variable...
                >
                >
                >
                >
                >
                >

                Comment

                • saurabh

                  #9
                  Re: changing value of html control from c# code in asp.net website

                  yeah exactly this is the prblm i am facing....after each trip to server
                  my html hidden control looses its value....if i am able to store this
                  value i think my problem will be solved...
                  no boss i dnt know abt this viewstate and all....i am kindaa new is
                  asp.net :(

                  Sean wrote:
                  just so i get an idea of your background do you know what viewstate is?
                  >
                  This will help me no repeat information that you already know.
                  >
                  "saurabh" wrote:
                  >

                  as per requirments this might not be possible in my case....Does any
                  body has idea at any one of the following:
                  1) To check if a server control radiobutton checked or not , using the
                  javascript, each time page is loaded....If u know tell me wht all steps
                  need to be taken.
                  2) or to change the value of a hidden html variable from inside the c#
                  code that we write in asp.net website....
                  -----------------

                  Sean wrote:
                  I think it might be easier just to use a server control becuase otherwise for
                  the most part the server doesnt even know it exists.
                  Depending on your needs that might be the best solution.
                  >
                  even if you went the route of having the server re-create the html control
                  on each load/postback it would take as much server "power" as it would to
                  just use a server control
                  >
                  "saurabh" wrote:
                  >
                  Can anybody tell me how to change the value of an html control from the
                  c#....
                  eg i hv one asp.net radio button control and one html hidden
                  variable...
                  so on page load in case the radio button is checked i want to set this
                  hidden variable to 1 else 0...

                  I am not getting what to write in Page_Load(objec t sender,
                  System.EventArg s e) function to change the value of this html
                  variable...

                  Comment

                  • Sean

                    #10
                    Re: changing value of html control from c# code in asp.net website

                    fair enough on viewstate that gives me a good idea in the area we are talking
                    about.

                    My question at this point would be why do you require a clientside HTML
                    checkbox instead of a serverside checkbox?

                    <asp:CheckBox ID="CheckBox1" runat="server" />

                    above will maitain state of value automatically :)


                    "saurabh" wrote:
                    yeah exactly this is the prblm i am facing....after each trip to server
                    my html hidden control looses its value....if i am able to store this
                    value i think my problem will be solved...
                    no boss i dnt know abt this viewstate and all....i am kindaa new is
                    asp.net :(
                    >
                    Sean wrote:
                    just so i get an idea of your background do you know what viewstate is?

                    This will help me no repeat information that you already know.

                    "saurabh" wrote:
                    >
                    as per requirments this might not be possible in my case....Does any
                    body has idea at any one of the following:
                    1) To check if a server control radiobutton checked or not , using the
                    javascript, each time page is loaded....If u know tell me wht all steps
                    need to be taken.
                    2) or to change the value of a hidden html variable from inside the c#
                    code that we write in asp.net website....
                    -----------------
                    >
                    Sean wrote:
                    I think it might be easier just to use a server control becuase otherwise for
                    the most part the server doesnt even know it exists.
                    Depending on your needs that might be the best solution.

                    even if you went the route of having the server re-create the html control
                    on each load/postback it would take as much server "power" as it would to
                    just use a server control

                    "saurabh" wrote:

                    Can anybody tell me how to change the value of an html control from the
                    c#....
                    eg i hv one asp.net radio button control and one html hidden
                    variable...
                    so on page load in case the radio button is checked i want to set this
                    hidden variable to 1 else 0...
                    >
                    I am not getting what to write in Page_Load(objec t sender,
                    System.EventArg s e) function to change the value of this html
                    variable...
                    >
                    >
                    >
                    >
                    >
                    >

                    Comment

                    • saurabh

                      #11
                      Re: changing value of html control from c# code in asp.net website

                      hey its kindaa difficult to explain u my prob this way...can u gimme ur
                      messenger contact(if u dnt mind)....will tell u thr...
                      hey i am working on this html variable in a javascript....i f i put
                      checkbox instead of tht it wont be possible to manipulate tht asp
                      checkbox frm javascript written in html control

                      Sean wrote:
                      fair enough on viewstate that gives me a good idea in the area we are talking
                      about.
                      >
                      My question at this point would be why do you require a clientside HTML
                      checkbox instead of a serverside checkbox?
                      >
                      <asp:CheckBox ID="CheckBox1" runat="server" />
                      >
                      above will maitain state of value automatically :)
                      >
                      >
                      "saurabh" wrote:
                      >
                      yeah exactly this is the prblm i am facing....after each trip to server
                      my html hidden control looses its value....if i am able to store this
                      value i think my problem will be solved...
                      no boss i dnt know abt this viewstate and all....i am kindaa new is
                      asp.net :(

                      Sean wrote:
                      just so i get an idea of your background do you know what viewstate is?
                      >
                      This will help me no repeat information that you already know.
                      >
                      "saurabh" wrote:
                      >

                      as per requirments this might not be possible in my case....Does any
                      body has idea at any one of the following:
                      1) To check if a server control radiobutton checked or not , using the
                      javascript, each time page is loaded....If u know tell me wht all steps
                      need to be taken.
                      2) or to change the value of a hidden html variable from inside the c#
                      code that we write in asp.net website....
                      -----------------

                      Sean wrote:
                      I think it might be easier just to use a server control becuase otherwise for
                      the most part the server doesnt even know it exists.
                      Depending on your needs that might be the best solution.
                      >
                      even if you went the route of having the server re-create the html control
                      on each load/postback it would take as much server "power" as it would to
                      just use a server control
                      >
                      "saurabh" wrote:
                      >
                      Can anybody tell me how to change the value of an html control from the
                      c#....
                      eg i hv one asp.net radio button control and one html hidden
                      variable...
                      so on page load in case the radio button is checked i want to set this
                      hidden variable to 1 else 0...

                      I am not getting what to write in Page_Load(objec t sender,
                      System.EventArg s e) function to change the value of this html
                      variable...


                      Comment

                      • Sean

                        #12
                        Re: changing value of html control from c# code in asp.net website

                        email me at sw@technologyce rtified.com

                        for grins see the app I am currently working on


                        I have some issues with the test grid and I dont know how far it goes so
                        results right now are somewhat unpredictable.

                        "saurabh" wrote:
                        hey its kindaa difficult to explain u my prob this way...can u gimme ur
                        messenger contact(if u dnt mind)....will tell u thr...
                        hey i am working on this html variable in a javascript....i f i put
                        checkbox instead of tht it wont be possible to manipulate tht asp
                        checkbox frm javascript written in html control
                        >
                        Sean wrote:
                        fair enough on viewstate that gives me a good idea in the area we are talking
                        about.

                        My question at this point would be why do you require a clientside HTML
                        checkbox instead of a serverside checkbox?

                        <asp:CheckBox ID="CheckBox1" runat="server" />

                        above will maitain state of value automatically :)


                        "saurabh" wrote:
                        yeah exactly this is the prblm i am facing....after each trip to server
                        my html hidden control looses its value....if i am able to store this
                        value i think my problem will be solved...
                        no boss i dnt know abt this viewstate and all....i am kindaa new is
                        asp.net :(
                        >
                        Sean wrote:
                        just so i get an idea of your background do you know what viewstate is?

                        This will help me no repeat information that you already know.

                        "saurabh" wrote:

                        >
                        as per requirments this might not be possible in my case....Does any
                        body has idea at any one of the following:
                        1) To check if a server control radiobutton checked or not , using the
                        javascript, each time page is loaded....If u know tell me wht all steps
                        need to be taken.
                        2) or to change the value of a hidden html variable from inside the c#
                        code that we write in asp.net website....
                        -----------------
                        >
                        Sean wrote:
                        I think it might be easier just to use a server control becuase otherwise for
                        the most part the server doesnt even know it exists.
                        Depending on your needs that might be the best solution.

                        even if you went the route of having the server re-create the html control
                        on each load/postback it would take as much server "power" as it would to
                        just use a server control

                        "saurabh" wrote:

                        Can anybody tell me how to change the value of an html control from the
                        c#....
                        eg i hv one asp.net radio button control and one html hidden
                        variable...
                        so on page load in case the radio button is checked i want to set this
                        hidden variable to 1 else 0...
                        >
                        I am not getting what to write in Page_Load(objec t sender,
                        System.EventArg s e) function to change the value of this html
                        variable...
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >

                        Comment

                        Working...