•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 363,497 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,321 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 247 | Replies: 1
•
•
Join Date: May 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
I have several listboxes in 1 page and there is a "search" button.Whenever user select any values from the listbox's and click search button the query fires and it is showing the desired results.But I want 2 more button on this page "save Query" and "Load Query".
Requirment is:
After selecting values from listboxes before pressing "search" button user should click "Save Query" button for saving his selected values and then he should press search button.Now when the user log in next time if he clicks "Load Query" Button he can see his selected values that he had selected last time.
Actually my application runs on windows authentication.No login user id password is nesessary.So there is no database fields for that.
I want to store listbox selected item in cookies.
Right Now the value is saving in the Cookies but only the last selected value.Please see in my No:2 section for the code that I wrote.
I Tried my code like this but facing some problem:
1)After saving the values if I close the application and again come back to that particular page the values is not selected......
I am writing this code in a click event of a button.
string val=Request.Cookies["toton"].Value;
if(val != null)
{
ListBox1.SelectedValue=val;
}
It is throwing error:Object reference not set to an instance of an object.
System.NullReferenceException.
2)I have several listBoxes.But in cookies it is always saving the last listbox value.Not all the selected value.
I am using this code:
Here always ListBox2.SelectedItem.Text is saving in Cookies.
3)There are 10 ListBoxes in that page.Its not mandetory user will select all the List Boxes.
So if in any situation user is selecting 4 of them,those all 4 values should be saved in cookies and in next login those 4 should be selected.
Can anyBody help me in this regards......
Requirment is:
After selecting values from listboxes before pressing "search" button user should click "Save Query" button for saving his selected values and then he should press search button.Now when the user log in next time if he clicks "Load Query" Button he can see his selected values that he had selected last time.
Actually my application runs on windows authentication.No login user id password is nesessary.So there is no database fields for that.
I want to store listbox selected item in cookies.
Right Now the value is saving in the Cookies but only the last selected value.Please see in my No:2 section for the code that I wrote.
I Tried my code like this but facing some problem:
1)After saving the values if I close the application and again come back to that particular page the values is not selected......
I am writing this code in a click event of a button.
string val=Request.Cookies["toton"].Value;
if(val != null)
{
ListBox1.SelectedValue=val;
}
It is throwing error:Object reference not set to an instance of an object.
System.NullReferenceException.
2)I have several listBoxes.But in cookies it is always saving the last listbox value.Not all the selected value.
I am using this code:
asp Syntax (Toggle Plain Text)
HttpCookie MyCookie = new HttpCookie("toton"); MyCookie.Value = ListBox1.SelectedItem.Text; MyCookie.Value=ListBox2.SelectedItem.Text; MyCookie.Expires=DateTime.MaxValue; Response.Cookies.Add(MyCookie);
Here always ListBox2.SelectedItem.Text is saving in Cookies.
3)There are 10 ListBoxes in that page.Its not mandetory user will select all the List Boxes.
So if in any situation user is selecting 4 of them,those all 4 values should be saved in cookies and in next login those 4 should be selected.
Can anyBody help me in this regards......
Last edited by peter_budo : May 11th, 2008 at 5:25 am. Reason: Keep It Organized - please use [code] tags
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
Other Threads in the ASP.NET Forum
- Previous Thread: ASP.Net timer control
- Next Thread: Copy Items from one combobox to another on Button Click



Threaded Mode