Retrieve value of an asptextbox

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

    Retrieve value of an asptextbox

    I am using Web Developer Express 2005. I created a little form to add
    some content to a database. I keep the formview default mode in the
    insert mode. The values are being added to the database fine.

    How do I retrieve a value of one of the textboxes and assign it to a
    variable so I can pass it along to a new page after the insert event?

    Thanks
  • Mark Rae [MVP]

    #2
    Re: Retrieve value of an asptextbox

    "Michael" <bgreer5050@gma il.comwrote in message
    news:aa655f34-8d02-4917-8935-3e3e757ef009@z7 2g2000hsb.googl egroups.com...
    How do I retrieve a value of one of the textboxes and assign it to a
    variable so I can pass it along to a new page after the insert event?
    string strMyVariable = MyTextBox.Text;


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • Michael

      #3
      Re: Retrieve value of an asptextbox

      Mark,

      Dont I have to use some type of findcontrol method ?

      Thanks

      Comment

      • Mark Rae [MVP]

        #4
        Re: Retrieve value of an asptextbox

        "Michael" <bgreer5050@gma il.comwrote in message
        news:dcbcc735-1da0-4539-bff5-956ba6fd52f6@8g 2000hse.googleg roups.com...
        Dont I have to use some type of findcontrol method ?
        Not unless the TextBox is contained within something like a GridView or a
        UserControl etc...

        If it's just on the page, then you can refer to it explicitly:



        --
        Mark Rae
        ASP.NET MVP


        Comment

        • Hans Kesting

          #5
          Re: Retrieve value of an asptextbox

          After serious thinking Michael wrote :
          I am using Web Developer Express 2005. I created a little form to add
          some content to a database. I keep the formview default mode in the
          insert mode. The values are being added to the database fine.
          >
          How do I retrieve a value of one of the textboxes and assign it to a
          variable so I can pass it along to a new page after the insert event?
          >
          Thanks
          If you want to "pass variables to another page", then a regular
          variable is not enough: After a redirect to that other page all your
          variables are cleared.
          But this is a very common situation, so there is a common solution:
          store the values in Session.

          example in C#:

          Session["MyValue"] = "Some Value";

          string s = (string)Session["MyValue"];

          Note: everything is stored as "object", so you need to cast to the
          proper type.


          Hans Kesting


          Comment

          Working...