I guess I am asking for a bit of help with the logic of the app im working on.
I am creating a blog tool for my intranet site and I want to show all the blogs for specific person
Well when u click on that person I want to pass a value to the sql query to filter for just that user.
I am using an image button in a repeater to access the second page
what is the best way to pass the unique value? I dont want to pass in querystring..
I really don't think there is a "best" way. There are several ways. My favorite these days is using the "session" variables:
' create session on first page
Session("Name") = textbox1.text ' or the image button value
Response.Redirect("Page2.asxp")
'retrieve session on landing page
If(Session("Name") is dbnull.value then
' don't do anything
else
' Label3.text = Session("Name").toString
End If
Then you can use the value in Label3.text or, just use the session name in your query string:
"SELECT [field names] FROM [tableName] WHERE [field] = session("Name")"
But it would probably be best to use a string variable:
Dim strPerson = Session("Name").toString
"SELECT [field names] FROM [tableName] WHERE [field] = strPerson"
Have fun!
SMC
"I have not failed. I just found 10,000 ways that don't work." - Thomas Edison
Marked as answer by cwfontan on Apr 16, 2009 06:52 PM
The best and secured way to pass values from page to page is a Session Variable.
You can just store your data in the session variable and retrieve it anytime you want.
In your project if you want all the blog as well as the blog for that particular user then you can retrieve the "All" records in a datatable or dataset and store it in a session variable and filter this stored datatable whenever and however rquired. This
would save your frequent trips to the database and hence the load would be faster.
Here's a nice, simple way to pass values from one page to another:
Add data to the context object before transferring
Context.Items("myParameter") = x;
Server.Transfer("WebForm2.aspx");
Then, in WebForm2.aspx:
'Grab data from the context property
I guess I am asking for a bit of help with the logic of the app im working on.
I am creating a blog tool for my intranet site and I want to show all the blogs for specific person
Well when u click on that person I want to pass a value to the sql query to filter for just that user.
I am using an image button in a repeater to access the second page
what is the best way to pass the unique value? I dont want to pass in querystring..
cwfontan
Member
178 Points
141 Posts
best way to pass values from page to page via link, button, hidden field, etc..
Apr 13, 2009 08:51 PM|LINK
I guess I am asking for a bit of help with the logic of the app im working on.
I am creating a blog tool for my intranet site and I want to show all the blogs for specific person
Well when u click on that person I want to pass a value to the sql query to filter for just that user.
I am using an image button in a repeater to access the second page
what is the best way to pass the unique value? I dont want to pass in querystring..
smcmiata
Participant
998 Points
297 Posts
Re: best way to pass values from page to page via link, button, hidden field, etc..
Apr 13, 2009 10:35 PM|LINK
I really don't think there is a "best" way. There are several ways. My favorite these days is using the "session" variables:
' create session on first page
Session("Name") = textbox1.text ' or the image button value
Response.Redirect("Page2.asxp")
'retrieve session on landing page
If(Session("Name") is dbnull.value then
' don't do anything
else
' Label3.text = Session("Name").toString
End If
Then you can use the value in Label3.text or, just use the session name in your query string:
"SELECT [field names] FROM [tableName] WHERE [field] = session("Name")"
But it would probably be best to use a string variable:
Dim strPerson = Session("Name").toString
"SELECT [field names] FROM [tableName] WHERE [field] = strPerson"
Have fun!
SMC
amita.deo
Member
42 Points
33 Posts
Re: best way to pass values from page to page via link, button, hidden field, etc..
Apr 14, 2009 07:11 AM|LINK
The best and secured way to pass values from page to page is a Session Variable.
You can just store your data in the session variable and retrieve it anytime you want.
In your project if you want all the blog as well as the blog for that particular user then you can retrieve the "All" records in a datatable or dataset and store it in a session variable and filter this stored datatable whenever and however rquired. This would save your frequent trips to the database and hence the load would be faster.
Try it out.
Amita
getchinna_sv
Star
12043 Points
2096 Posts
Re: best way to pass values from page to page via link, button, hidden field, etc..
Apr 14, 2009 07:23 AM|LINK
Here's a nice, simple way to pass values from one page to another:
Add data to the context object before transferring
Context.Items("myParameter") = x;
Server.Transfer("WebForm2.aspx");
Then, in WebForm2.aspx:
'Grab data from the context property
int x = (int)Context.Items("myParameter");
Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/is...e/default.aspx
http://www.aspalliance.com/kenc/passval.aspx
http://www.dotnetbips.com/displayarticle.aspx?id=79
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: best way to pass values from page to page via link, button, hidden field, etc..
Apr 14, 2009 07:30 AM|LINK
Here all methods are discussed
http://www.worldofasp.net/tut/redirect/Passing_Values_from_One_Page_to_Another_in_ASPNET_152.aspx
Sessions and CrossPost Back is best
Contact me
cwfontan
Member
178 Points
141 Posts
Re: best way to pass values from page to page via link, button, hidden field, etc..
Apr 15, 2009 06:14 PM|LINK
This may be a great way to do it. Then I could use a hidden panel on the same page with an onclick event to show the data fast.
Any examples of this would be helpful.
thanks