ASP:TextBox

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

    ASP:TextBox

    I am a newbie to ASP.NET...

    What I was trying to do... but yet to succeed in...

    I am building a customer info database... and on default,
    I want to display the customer's basic information in the
    TextBox on Page_Load... but, also allow user to update the
    information

    For example: Street1 of the home address
    ASP:TextBox id=dbStreet1 value=<%=litDbS treet1%>

    but also allow update all within the same form on the same
    text box to do the following...
    ASP:TextBox id=dbStreet1 runat=server

    I tried everything I know... but not works...

    Please advise
    thanks
    Alex
  • George Zacharias

    #2
    Re: ASP:TextBox

    Try the attribute "text" instead of "value".

    The best way to do this is declare an ASP textbox in the code-behind page
    and assign the value of the variable to dbStreet1.Text from the Page_Load
    event.

    George Zacharias.

    "Alex" <alexcfwu@gwu.e du> wrote in message
    news:006801c343 07$06628da0$a10 1280a@phx.gbl.. .[color=blue]
    > I am a newbie to ASP.NET...
    >
    > What I was trying to do... but yet to succeed in...
    >
    > I am building a customer info database... and on default,
    > I want to display the customer's basic information in the
    > TextBox on Page_Load... but, also allow user to update the
    > information
    >
    > For example: Street1 of the home address
    > ASP:TextBox id=dbStreet1 value=<%=litDbS treet1%>
    >
    > but also allow update all within the same form on the same
    > text box to do the following...
    > ASP:TextBox id=dbStreet1 runat=server
    >
    > I tried everything I know... but not works...
    >
    > Please advise
    > thanks
    > Alex[/color]


    Comment

    • Alex

      #3
      Re: ASP:TextBox

      Hi,

      This is what I did...

      Page_Load()
      dbStreet1.Text = "whatever st"

      Update_Text()
      SQL update cmd ==> "update ..... dbstreet1='" &
      dbStreet1.Text "' where <match critera>=<match this>"

      Inside the HTML Main Body
      <form method=post>
      <ASP:TextBox id=dbStreet1 value=dbStreet1 .Text
      runat=server/>
      </form>

      It works on initial load.. where it takes the info from
      DB... but the update doesn't seem to regonize the new value

      Any clue?
      thanks
      Alex[color=blue]
      >-----Original Message-----
      >Try the attribute "text" instead of "value".
      >
      >The best way to do this is declare an ASP textbox in the[/color]
      code-behind page[color=blue]
      >and assign the value of the variable to dbStreet1.Text[/color]
      from the Page_Load[color=blue]
      >event.
      >
      >George Zacharias.
      >
      >"Alex" <alexcfwu@gwu.e du> wrote in message
      >news:006801c34 307$06628da0$a1 01280a@phx.gbl. ..[color=green]
      >> I am a newbie to ASP.NET...
      >>
      >> What I was trying to do... but yet to succeed in...
      >>
      >> I am building a customer info database... and on[/color][/color]
      default,[color=blue][color=green]
      >> I want to display the customer's basic information in[/color][/color]
      the[color=blue][color=green]
      >> TextBox on Page_Load... but, also allow user to update[/color][/color]
      the[color=blue][color=green]
      >> information
      >>
      >> For example: Street1 of the home address
      >> ASP:TextBox id=dbStreet1 value=<%=litDbS treet1%>
      >>
      >> but also allow update all within the same form on the[/color][/color]
      same[color=blue][color=green]
      >> text box to do the following...
      >> ASP:TextBox id=dbStreet1 runat=server
      >>
      >> I tried everything I know... but not works...
      >>
      >> Please advise
      >> thanks
      >> Alex[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Alex

        #4
        Re: ASP:TextBox

        Hi,

        This is what I did...

        Page_Load()
        dbStreet1.Text = "whatever st"

        Update_Text()
        SQL update cmd ==> "update ..... dbstreet1='" &
        dbStreet1.Text "' where <match critera>=<match this>"

        Inside the HTML Main Body
        <form method=post>
        <ASP:TextBox id=dbStreet1 value=dbStreet1 .Text
        runat=server/>
        </form>

        It works on initial load.. where it takes the info from
        DB... but the update doesn't seem to regonize the new value

        Any clue?
        thanks
        Alex[color=blue]
        >-----Original Message-----
        >Try the attribute "text" instead of "value".
        >
        >The best way to do this is declare an ASP textbox in the[/color]
        code-behind page[color=blue]
        >and assign the value of the variable to dbStreet1.Text[/color]
        from the Page_Load[color=blue]
        >event.
        >
        >George Zacharias.
        >
        >"Alex" <alexcfwu@gwu.e du> wrote in message
        >news:006801c34 307$06628da0$a1 01280a@phx.gbl. ..[color=green]
        >> I am a newbie to ASP.NET...
        >>
        >> What I was trying to do... but yet to succeed in...
        >>
        >> I am building a customer info database... and on[/color][/color]
        default,[color=blue][color=green]
        >> I want to display the customer's basic information in[/color][/color]
        the[color=blue][color=green]
        >> TextBox on Page_Load... but, also allow user to update[/color][/color]
        the[color=blue][color=green]
        >> information
        >>
        >> For example: Street1 of the home address
        >> ASP:TextBox id=dbStreet1 value=<%=litDbS treet1%>
        >>
        >> but also allow update all within the same form on the[/color][/color]
        same[color=blue][color=green]
        >> text box to do the following...
        >> ASP:TextBox id=dbStreet1 runat=server
        >>
        >> I tried everything I know... but not works...
        >>
        >> Please advise
        >> thanks
        >> Alex[/color]
        >
        >
        >.
        >[/color]

        Comment

        • David Waz...

          #5
          Re: ASP:TextBox

          Alex,

          You have to read some fundamental books on ASPX programming - that's #1.
          There are bunches and bunches of inexpensive, quick, easy books on the
          subject.

          The Page_load event fires on every trip to your page, so you are overwriting
          the data changed on the site with the Page_Load event assignments.
          .... so, your fresh, new values are trampled on when you post back to
          update...

          events fired in this order:

          Init
          Load viewstate
          Process postback data (this is where your new data gets back to the
          application)
          Load (this is were you lose the data, and the original values are put back)
          Send postback Change
          Postback events
          pre-render
          save view state
          render
          dispose
          unload

          Learn it, love it, live it! :-)

          "Alex" <alexcfwu@gwu.e du> wrote in message
          news:006801c343 07$06628da0$a10 1280a@phx.gbl.. .[color=blue]
          > I am a newbie to ASP.NET...
          >
          > What I was trying to do... but yet to succeed in...
          >
          > I am building a customer info database... and on default,
          > I want to display the customer's basic information in the
          > TextBox on Page_Load... but, also allow user to update the
          > information
          >
          > For example: Street1 of the home address
          > ASP:TextBox id=dbStreet1 value=<%=litDbS treet1%>
          >
          > but also allow update all within the same form on the same
          > text box to do the following...
          > ASP:TextBox id=dbStreet1 runat=server
          >
          > I tried everything I know... but not works...
          >
          > Please advise
          > thanks
          > Alex[/color]


          Comment

          • Alex

            #6
            Re: ASP:TextBox

            Dave,

            Many thanks...

            The sequence of load instructions solve my problem...
            Basically I have everything else done right... Except, not
            checking explicitly for POST during Page_Load...

            I was basically counting on the even handler to trigger
            the event..

            Thank you
            Alex[color=blue]
            >-----Original Message-----
            >Alex,
            >
            >You have to read some fundamental books on ASPX[/color]
            programming - that's #1.[color=blue]
            >There are bunches and bunches of inexpensive, quick, easy[/color]
            books on the[color=blue]
            >subject.
            >
            >The Page_load event fires on every trip to your page, so[/color]
            you are overwriting[color=blue]
            >the data changed on the site with the Page_Load event[/color]
            assignments.[color=blue]
            >.... so, your fresh, new values are trampled on when you[/color]
            post back to[color=blue]
            >update...
            >
            >events fired in this order:
            >
            >Init
            >Load viewstate
            >Process postback data (this is where your new data gets[/color]
            back to the[color=blue]
            >application)
            >Load (this is were you lose the data, and the original[/color]
            values are put back)[color=blue]
            >Send postback Change
            >Postback events
            >pre-render
            >save view state
            >render
            >dispose
            >unload
            >
            >Learn it, love it, live it! :-)
            >
            >"Alex" <alexcfwu@gwu.e du> wrote in message
            >news:006801c34 307$06628da0$a1 01280a@phx.gbl. ..[color=green]
            >> I am a newbie to ASP.NET...
            >>
            >> What I was trying to do... but yet to succeed in...
            >>
            >> I am building a customer info database... and on[/color][/color]
            default,[color=blue][color=green]
            >> I want to display the customer's basic information in[/color][/color]
            the[color=blue][color=green]
            >> TextBox on Page_Load... but, also allow user to update[/color][/color]
            the[color=blue][color=green]
            >> information
            >>
            >> For example: Street1 of the home address
            >> ASP:TextBox id=dbStreet1 value=<%=litDbS treet1%>
            >>
            >> but also allow update all within the same form on the[/color][/color]
            same[color=blue][color=green]
            >> text box to do the following...
            >> ASP:TextBox id=dbStreet1 runat=server
            >>
            >> I tried everything I know... but not works...
            >>
            >> Please advise
            >> thanks
            >> Alex[/color]
            >
            >
            >.
            >[/color]

            Comment

            • Leonard

              #7
              Re: ASP:TextBox


              This event sequence, indeed, is discussed in several
              ASP.NET with varying degrees of clarity. The major theme
              in most books is to use the "if (!IsPostBack).. ." logic to
              get around the overwriting of variables in the viewstate.
              However, I am observing a difference in behavior between
              the asp:label control (where everything seems to work as I
              expect and state is preserved via the viewstate) and the
              asp:textbox where the state is not preserved in the
              viewstate. What is happening here? I think Alex and I
              are hitting the same problem.

              Also, the instance of the asp:textbox seems not to have
              been created in the init and when it is referenced in the
              Page_Load an exception is thrown because the object isn't
              there!

              What is happening with the asp:textbox?[color=blue]
              >-----Original Message-----
              >Alex,
              >
              >You have to read some fundamental books on ASPX[/color]
              programming - that's #1.[color=blue]
              >There are bunches and bunches of inexpensive, quick, easy[/color]
              books on the[color=blue]
              >subject.
              >
              >The Page_load event fires on every trip to your page, so[/color]
              you are overwriting[color=blue]
              >the data changed on the site with the Page_Load event[/color]
              assignments.[color=blue]
              >.... so, your fresh, new values are trampled on when you[/color]
              post back to[color=blue]
              >update...
              >
              >events fired in this order:
              >
              >Init
              >Load viewstate
              >Process postback data (this is where your new data gets[/color]
              back to the[color=blue]
              >application)
              >Load (this is were you lose the data, and the original[/color]
              values are put back)[color=blue]
              >Send postback Change
              >Postback events
              >pre-render
              >save view state
              >render
              >dispose
              >unload
              >
              >Learn it, love it, live it! :-)
              >
              >"Alex" <alexcfwu@gwu.e du> wrote in message
              >news:006801c34 307$06628da0$a1 01280a@phx.gbl. ..[color=green]
              >> I am a newbie to ASP.NET...
              >>
              >> What I was trying to do... but yet to succeed in...
              >>
              >> I am building a customer info database... and on[/color][/color]
              default,[color=blue][color=green]
              >> I want to display the customer's basic information in[/color][/color]
              the[color=blue][color=green]
              >> TextBox on Page_Load... but, also allow user to update[/color][/color]
              the[color=blue][color=green]
              >> information
              >>
              >> For example: Street1 of the home address
              >> ASP:TextBox id=dbStreet1 value=<%=litDbS treet1%>
              >>
              >> but also allow update all within the same form on the[/color][/color]
              same[color=blue][color=green]
              >> text box to do the following...
              >> ASP:TextBox id=dbStreet1 runat=server
              >>
              >> I tried everything I know... but not works...
              >>
              >> Please advise
              >> thanks
              >> Alex[/color]
              >
              >
              >.
              >[/color]

              Comment

              Working...