Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: From database to hidden form???


Message #1 by "Xiao Yu" <LingXiaoYu505@h...> on Fri, 13 Dec 2002 16:09:02
Hi,

I was trying to pull out a value from a table: user 
                                        Field: username
                        Lets say the value is: Ling

and then I want to put that value into a hidden form and upon submision
that value will be inserted into a different table called "otherinfo"

I have no problem with selecting and inserting the value into the 
database. But I don't know how I can pass it to the hidden form.

I know using php i can just pass the value to a string and put that 
string into the 'value' properties of the hidden form. but i dun think
it will fly here right? or probably done differently in .Net
that i dun understand it quite well

I also have follow the tutorial that uses datareader to extract the 
value into a string but the only thing is that the sample have the 
value passed into div tag while i wanted it to be passed into 
submitable form. 

this is some of the codes:

'within <script>
' the part that takes the value Email and put it into string.

  While objDataReader.Read()=True
    strResultsHolder +=objDataReader("Email")
  End While

  divUsername.innerHTML = strResultsHolder


'the HTML part
<div id="divUsername" runat="server"></div>


If anyone can point me to a link or explain how this can be done that 
will be great.

THANKS IN ADVANCE!

Ling
Message #2 by "Peter Lanoie" <planoie@n...> on Tue, 17 Dec 2002 09:44:52 -0500
It seems that the heart of your question is that you want to carry a
"hidden" value from one form to another, or at least from one post to
another.  Is this correct?

My suggestion for doing this is to use the viewstate.  In classic ASP, I
would do what you are attempting.  Put a hidden form element with that value
so it will carry thru to the form post.  Then you just grab it out of the
form values.  In .Net, you can accomplish essentially the same thing by
using the Viewstate:

	Viewstate("UserName") = <value from the database>

Then you can just pull that value back out of the viewstate when you need
it:

	<where I need the value> = Viewstate("UserName")

It's basically like using session variables, but they only live on the page
and they are embedded in that "__VIEWSTATE" hidden element in the HTML.  The
framework puts them in there along with all the other viewstate information
for your form.

HTH,

Peter

-----Original Message-----
From: Xiao Yu [mailto:LingXiaoYu505@h...]
Sent: Friday, December 13, 2002 16:09
To: aspx_beginners
Subject: [aspx_beginners] From database to hidden form???



Hi,

I was trying to pull out a value from a table: user
                                        Field: username
                        Lets say the value is: Ling

and then I want to put that value into a hidden form and upon submision
that value will be inserted into a different table called "otherinfo"

I have no problem with selecting and inserting the value into the
database. But I don't know how I can pass it to the hidden form.

I know using php i can just pass the value to a string and put that
string into the 'value' properties of the hidden form. but i dun think
it will fly here right? or probably done differently in .Net
that i dun understand it quite well

I also have follow the tutorial that uses datareader to extract the
value into a string but the only thing is that the sample have the
value passed into div tag while i wanted it to be passed into
submitable form.

this is some of the codes:

'within <script>
' the part that takes the value Email and put it into string.

  While objDataReader.Read()=True
    strResultsHolder +=objDataReader("Email")
  End While

  divUsername.innerHTML = strResultsHolder


'the HTML part
<div id="divUsername" runat="server"></div>


If anyone can point me to a link or explain how this can be done that
will be great.

THANKS IN ADVANCE!

Ling


  Return to Index