Hidden values

R

Roshawn Dawson

Hi,

Is it possible to pass the value of a hidden field in the querystring?
If not, how can you pass the value from page to page without using
server controls?

Thanks,
Roshawn
 
K

Ken Cox [Microsoft MVP]

Hi Roshawn,

Here's a way to pass values from one page to another without the messy
querystring.

You can pass Context and then use Server.Transfer. The code below shows the
starting page first and then the receiver page.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]


' Page with hidden textbox:

<form id="Form1" method="post" runat="server">
<p>
<asp:textbox id="TextBox1" runat="server"
visible="False">Pass this!</asp:textbox></p>
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
</form>

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Context.Items("txtValue") = TextBox1.Text
Server.Transfer("targetpg.aspx")
End Sub


' targetpg.aspx that shows the passed value

<form id="Form1" method="post" runat="server">
<asp:label id="Label1" runat="server">Label</asp:label>
</form>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = CType(Context.Items("txtValue"), String)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top