Monday, March 26, 2012

pass values

On my web page i'm passing in a value using request.querystring, but i need
this same value several other pages. How can I store this value and use it o
n my other pages to execute my SQL?
thxIn a session variable.
Eliyahu
"IGotYourDotNet" <IGotYourDotNet@.discussions.microsoft.com> wrote in message
news:C3EEF090-CC7C-4A13-83EF-C0D7A655B93E@.microsoft.com...
> On my web page i'm passing in a value using request.querystring, but i
need this same value several other pages. How can I store this value and use
it on my other pages to execute my SQL?
> thx
You say you're "passing in a value" - Where are you passing it from? Where
are you passing it to?
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"IGotYourDotNet" <IGotYourDotNet@.discussions.microsoft.com> wrote in message
news:C3EEF090-CC7C-4A13-83EF-C0D7A655B93E@.microsoft.com...
> On my web page i'm passing in a value using request.querystring, but i
need this same value several other pages. How can I store this value and use
it on my other pages to execute my SQL?
> thx
You can pass values between pages using a variety of methods - session
variables are common, as is using viewstate. I prefer to structure my code
really well and use properties via the refernce page directive. Theres a
small example below for you
Regards
John Timney
Microsoft Regional Director
Microsoft MVP
"IGotYourDotNet" <IGotYourDotNet@.discussions.microsoft.com> wrote in message
news:C3EEF090-CC7C-4A13-83EF-C0D7A655B93E@.microsoft.com...
> On my web page i'm passing in a value using request.querystring, but i
need this same value several other pages. How can I store this value and use
it on my other pages to execute my SQL?
> thx
PassingValuesPage.aspx
<%@. Page Language="VB" ClassName="FirstPageClass" %>
<html>
<head>
<script runat="server">
Public ReadOnly Property FirstName() As String
Get
' first is the name of a TextBox control.
Return first.Text
End Get
End Property
Public ReadOnly Property LastName() As String
Get
' last is the name of a TextBox control.
Return last.Text
End Get
End Property
Sub ButtonClicked(sender As Object, e As EventArgs)
Server.Transfer("ReceivingValuesPage.aspx")
End Sub
</script>
</head>
<body>
<form runat="server">
First Name:
<asp:TextBox id="first"
runat="server"/>
<br>
Last Name:
<asp:TextBox id="last"
runat="server"/>
<br>
<asp:Button
OnClick="ButtonClicked"
Text="Go to second page"
runat=server />
</form>
</body>
</html>
--recievingvalues.aspx
<%@. Page Language="VB" %>
<%@. Reference Page="passingValuesPage.aspx" %>
<html>
<head>
<script runat="server">
Dim fp As FirstPageClass
Sub Page_Load()
If Not IsPostBack Then
fp = CType(Context.Handler, FirstPageClass)
End If
End Sub
</script>
</head>
<body>
<form runat="server">
Hello <%=fp.FirstName%> <%=fp.LastName%>
</form>
</body>
</html>

0 comments:

Post a Comment