Hi I have a RadGrid in my asp.net application and basically I am being asked to persist the sorting clicked on the header name throught out the user session so basically lets say I have the RadGrid with the following headings.
ID Name OrderNumber Shipped
So by default it is sorted in ASC order by name when you first arrive at the page, but now.. if the User resorts it by clicking on the Name heading again it will make it in DESC order. So what I am being asked to do is to make the web remember the sorting option no matter if the user navigates to a different page within the application. So when the user comes back he should see the gridview in the order he/she picked before leaving to another page within the appliacation.
How can I do this with a RadGrid, without using HttpCookie ?
I do not think I should show my code as it is the plain default set up of a RadGrid BUT if necessary I will just grab something and put it here, I am just not sure the best way to go about it.
Thank you
I don't think this is a feature that we should be looking from a third party control, rather than an implementation item when using it in a project.
So if the requirement is only to persist within the user session, HttpCookie or even ASP.Net session would work. But if the requirement is to maintain even across same users next log-ins, even database would be a go od option rather than putting the weight on the ASP.Net session or Cookie transferring client to server every time.
Related
I am developing a mvc 5 web application which allow user to select language and currency to be displayed to them, in which the choice of language and currency they selected is expected to be retrievable throughout the controller and view.
Do note that the user i referring here is anonymous user (which is user that do not log in) so i do not intend to save their selection to database.
I am thinking of using session to store the selection. However, it seems not a good choice of to me as these are only two values that i need to store in session. Is there any other better alternative?
An alternative is to put language in url
{language}/{controller}/{action}/{id}
e.g.
en/home/index
fr/home/index
Advantage is that the url is bookmarkable and clearer
An example implementation: http://adamyan.blogspot.sg/2010/07/addition-to-aspnet-mvc-localization.html
For currency, I'll probably determine it from the culture of user, or at least use that value as default for first time user. If you want to let user be able to change it, cookie is fine in my opinion.
I've got a problem that may either be a limitation in my approach or asp.net web forms technology. The main driver for this solution is the simple fact that when users sit on an individual page for an extended period of time, they are redirected to our CAS server and back to the page itself which results in all of the form inputs being cleared as if the user did not enter any information (i.e. losing the ViewState/control state). With that being said I was exploring other options such as:
Using HTML localStorage to store a JSON string of all values on the page that can be parsed into an object and loaded into the form later if needed.
Even though this solution allowed me to store values on each page in individual key/value pairs (page instance 1 in localStorage[ID1], page instance 2 in localStorage[ID2] etc.), there was still a limitation on the server side of validating which page the user is saving. Right now I am using the session to maintain which form the user is viewing ie. the user is only associated with 1 page. To continue the example, the session information would result in the user being associated with either localStorage[ID1] or localStorage[ID2], not both ---which is precisely my problem. I need to communicate from the client-side which one page is to be saved. I've explored the following options, and come up with the following questions:
A static class that contains a static collection of objects on the server side storing which users have which pages open--> problem: communicating which page is actually being saved.
Dynamically rendering my save buttons with IDs that include an encrypted version of the page identifier at hand.
Storing the current value being edited in the Querystring
A cookie value that stores the value of the ID that the user wishes to change on post back-->how will the cookie get its value--especially when an ID is new (user is filling out form for the first time)?
I may be over complicating this and I know there is an easier way.
Many sites solve this problem by displaying a dialog when the user has sat on the page too long, asking if they still want to maintain their session. If the user doesn't click "Yes", then lose the session.
Another solution would be to permit a user who knows he's going to not use the page for a while to save the results so far and to restore them later, and continue.
Before proceeding with a technological solution, I'd try to find out why the users are sitting on the page so long. Whatever their reason is, you'll want to try to accommodate it if it's a good reason.
If the reason is "because we don't really care about your page and just didn't bother to close it", then your current solution works fine.
I just wanted to close out my own issue. I will resolve my problem by storing encrypted values in the query string to maintain page state. From there I will all values the user enters on the page within stringified json objects within localStorage. For example: page 1 with id: aa will have one key value pair within localStorage in the format [appName_pageId]. Page 2 with id bb will have a similar key value pair. If the user gets redirected to our CAS server and lands back on my page with all values cleared, I will be able to load the correct inputs from localStorage based on the value in the query string parameter (aa or bb). The important principle to remember here is that central control belongs on the server and distributed control should be done on the client.
I have a page where a user can enter information into text boxes and upon submitting the information is saved to the database and the information is added to a gridview that they can select and edit the records from.
They shouldnt ever, but if they delete a record hit the back button in a browser and then select the record in the gridview again they are going to get out of range error because the record no longer exists in the database.
So I am looking for ideas on how to best keep this scenario from happening. Any suggestions are appreciated and i will be checking frequently to provide any additional information as I know this might be a little vague.
You should always handle the case where a user selects a record that does not exist because of the inherit nature of web applications...the data is stale as soon as the user sees it.
Even if the user just displayed the page for the first time it is possible another user deleted the record just after the results were retrieved.
I would suggest checking to see if the record exists, prompting the user in some manner that the data is stale and refresh the list automatically.
You could temporarily disable the back button with javascript?
http://csharpdotnetfreak.blogspot.com/2009/04/disable-browser-back-button-javascript.html
I have a search page which includes a data list and a pannel to either perform search by keywords or by filtering criteria (something similar to http://shutr.bz/KpZk2p)
I have wrapped the data-list inside a <contentTemplate> and registered the search button as <trigger>, so when somebody either enters a keyword or filter's by criteria and click on button, the system build a query based upon the entered values, query database and load data-list, everything works perfect, BUT
Now there is a change in business requirement where I need to make this search a query string based search, so if one user have filtered down the data (building the search filter) then user can share the results with the subordinates just sharing the URL.
I know this needs something like response.redirect on button click and passing the entered values queryString and then read the URL on page load for the passed values.
Well I really looking for a best mechanism to implement this, since the data-list displays the images from DB and hence needs to be a quicker and effective.
Suggestions would be highly appreciable.
Thanks a lot on advance.
I've written a Navigation project that will help you, http://navigation.codeplex.com/.
On the documentation page, http://navigation.codeplex.com/documentation, I go through building a sample that does exactly what you want. It uses ASP.NET Ajax with Ajax History support to provide bookmarking.
We have a Review System in place where I work. A manager selects an employee to review, which then sets the EmployeeID as a Session["EmpID"] variable. Now, the manager can enter in the information for the said employee.
Our Issue:
When a manager opens another tab or window in the browser (ie. Internet Explorer), searches for a different employee, it sets Employee #2 ID as the Session["EmpID"] variable, over-writing the first one. When the manager switches back to Employee #1 and enters information, they believe they are entering information for #1, however it enters it as #2 since they selected it last.
Does anyone have ideas to prevent this from happening?
When using tabbed browsing you actually use the same asp.net session, and therefore, if you don't uniquely seperate one page's cache from the others, you get the same data.
If your pages uses the session to store data, use a unique identifier (such as a GUID) as a prefix for the key. Store the guid in a hiddenfield or in the ViewState.
Maybe it'll suffice to store the EmpID in the ViewState. Then Tab1 will keep it's value even if Tab2 had another value.
ASP.NET session id shared amongst browser tabs
Way around ASP.NET session being shared across multiple tab windows
http://forums.asp.net/t/1227829.aspx/1
It sounds more feasible to store the empID in a hidden field/tag in the contents of the page. Save your record based off that string record = span.innerText , because that will be on the page not the session