i have a ajaxified list page showing some list of items i am using a user control for filtering the content of the list page there are multiple filters in the user control what i want is if a user applied more than one filter than navigate to other page and press the back button the applied filters should be there in active state.
can any one please suggest me something how to achieve this.
You should put the filters in the query string because:
(1)It's not secret data.
(2)When user click "back" button of the browser, of course he wants the list is well-filtered, instead of that he need to filter the list again. Also sometimes he may copy the url in the address bar and sent it to others.
Format the filters' info in a proper way, e.g. "filter1=name&filter2=price", and deal with the query string in Page_Load if there is a filter.
One way is using cookies.
Store the values in a cookie, and read them back with javascript when the user hits the back button.
Or use the querystring like #Danny says. Why didn't I think of that right away :)
Related
I am using C# MVC for my project.
In Home page, I am rending one action using razor syntax.
Index.chtml Page
<div>
#Html.RenderAction("OrganizationManagerData","Home")
</div>
When I first time load Index page, "OrganizationManagerData" method also render and it shows employee data with all who are working under him/her in Tabular format.
Logged In manager can do many things in that like provide feedback to individual, give task, submit performance report of individual to higher authority, so on.
We have one more option on Index Page "Filter" when Manager clicks on it, it will show popup and can select the filter which needs like good performer, avg Performer, by task, so on.
What I want to achieve is when manager select Filters and click Apply, I want to re-render the table so that it will display filtered data.
What I am thinking is When user will click on "Apply", will call again DB and will show filtered Data
Is it good approach however I don't know how to re-render the "OrganizationManagerData" action again on Apply Click?
Or
Is it any better way to do it?
What is usually best practice to display intuitive dashboard which have loads of data.
Would like to hear your opinion.
Thanks in advance.
I just thought of maybe I will call Ajax for OrganizationManagerData and it will return json format which I will use to format table in JS.
However for this have to write lots of html in Javascript.
I have hide the rows which are not matching with my filter condition using JavaScript.
I've two text boxes in one page and after those text boxes two separate search buttons, search buttons redirect to another page where user searchs and result is displayed in a grid, there can be multiple results, each row of grid contains 'select' command so that when user clicks on select of perticular row its data is selected and page redirects to previous page and data of row is displayed in textbox..
I've done so far. This is what I want to do:
Since there are two textboxes, two separate search buttons, what I am experiencing is when user selects 1st data for 1st textbox and searchs for 2nd text box then while returning for 1st page after 2nd search, 1st textbox becomes empty, What I want is that it should contain the value user has entered before.
textboxes should keep the value. If searching for 1st text box then 2nd should keep its value and if searching for 2nd text box 1st should keep its value.
I am using response.redirect method in dg_RowCommand event. I think by this page is rendering with its initial values which is what I don't want.
kindly tell me the solution I have searched so much but came up with nothing.
You can store the values in either Cookie or in a Session variable. Session variable is application specific and cookies are browser specific.
try this, for creating a session variable
Session["key"] = "your value"
or
for Cookie
Response.Cookies["key"].Value ="your value"
on the another page check first is it not null
if(Session["key"]!=null)
// use it
and same for the cookie (access it with Request object)
if (Request.Cookies["key"] != null)
// use it
use Session variable. Session["YourKey"] = your value; You can access it cross page
Update:
If I am right then you are thinking of some wizard type interface. If you can take benefit of ASP.Net Wizard control then look into this. It might help you.
Combine the pages into one, with each page(step) becoming a div or asp:Panel. hide/show divs rather than "navigate to the next page" on Click_Next event (or whatever). This way all controls stay on the same page and maintain all values when the divs are shown/hidden. No Session or other methods needed.
If you are redirecting with the Response.Redirect method in the C# Code then before you execute this redirect you can store the items in Session variables:
Session["Test1"] = test1.Text;
Sessions are maintained per user. These will be retained for as long as the application is running, but be warned that if an Application timeout occurs or the user closes the application (closes browser) these values will be lost.
I have to create a data entry form in asp.net webforms where the user could enter several member details. Each member detail will have about twenty data items such as FirstName, Lastname, DateOfBirth etc. The number of members entered can be anywhere from one to say twenty.
Once all the members entered or during the entry process, they should be able to go to the previous or next entry and make changes. Essentially there should be a Next and Previous buttons which will traverse the pages. At the end when the Save button is clicked all the entered data should be saved.
I have created a UserControl, which has all the textboxes to enter data. I have created five hardcoded panels which display the usercontrol five times. This makes the total members that could entered as five.
I would like to replace this hardcoded model with a dynamically added panel, when the next button is clicked.
Please let me know how this could be achieved. Or if there is a better architecture please let me know. I tried the wizard control, but it was too cumbersome in maintaining the previously entered values and traversing data using Next and Previous buttons.
Thanks
You could add the controls dynamically to the page using:
Page.Controls.Add(new MyControl());
You'll have to find a temporary store for the data entered in the controls though such as Session.
Session["addedControls"] = myControls;
You can track the number of controls they add and then loop though and save all the data to whatever permanent store you're using.
There's an example of this here: http://howto.jamescarnley.com/2008/05/adding-fields-dynamically-in-aspnet.html
Storing the entire control in session does have it's drawbacks such as the overhead involved, you could just store the data which is more efficient but is a tiny bit more effort to implement.
This will also only work if they have cookies enabled.
Alternatively you could have a drop down list for them to select the number of entries they wish to make and display that number of controls by calling Page.Controls.Add the number of required times. Then just save them all in bulk at the end.
You could dynamically add the controls you need to input a new member easily enough in javascript. What you propose sounds like a nightmare to me. I'd put up a page with the controls to add a member and an 'Add Member' button. When the Add Member button is clicked - I would save the member to the database, retrieve a list of members added in this session - and display the names of the members in a list to the right of the 'Add Member' area of the page. If they want to review a member they can click on their name and you can show that member ready to be edited. Or they can add another member until they have finished. What you are trying to do is going to be a nightmare to manage and won't be any easier for the user to use.
Using dynamic controls will be very difficult and not user friendly as it may require refresh the page or using update panel
in your case, I would recommend doing it all from JavaScript using Knockout, This is a full sample Knockout Grid
Make sure after adding or editing the grid, you will serialize the JavaScript objects into string using JSON.Stringify and add this text to a hidden field.
On form submission, just get the hidden field value, use newtonsoft json library to convert the string into an object and fee free to use the object which will be a list of your model (ex: Order).
Compared to dynamic controllers, this is more manageable and user friendly
I want to show a confirmation message on click of cancel button and then redirect to another page. But the confirmation message should come only if any change has been done on the page.
Please can anyone help on this. Is it possible to achieve this at client side or at server side without comparing data ?
Thanks in advance.
I'm guessing you could have a scenario where:
A form is populated with values and each form item that you are tracking for changes also has a corresponding hidden field.
If the user clicks submit = great, but if the user clicks cancel you want to loop through each form item, comparing it to it's original value stored in the hidden field. If a change is detected you want to show a pop-up window informing the user that if they cancel their changes will lost - or something like that.
You can do all this on the client. JQuery, or Knockout (which I would use) or Backbone (I don't know this one tbh) should all provide a neat way to achieve this.
If you can't have hidden fields you might want to send the new values to the server in an Ajax post, get the server to pull the original values, compare and send back an appropriate response to the client. I'm sure there are other ways too*.
edit: like pop the original values in an array via Javascript, then compare them. Anyway, I'm sure you get the idea :)
This could be accomplished using jquery you would need to compare data since you want the message to come up when the cancel button is clicked.
jquery reference
I'm new to ASP.NET. I'm designing a user interface in Asp.NET and C# where the user can login and then launch an application. When using this application the user has to fill out a form that is 10 pages long.
So, I have used navigation menu and designed the interface in such a way where every page is different menu item and it is a static menu. The user fills out the details on the first page of the form and saves it and the data gets saved in the database.
The problem is he moves to the other page by clicking the menu tab; when he comes back to the first page by using the menu tab for that page all the filled in data is gone and he sees a blank page. I know that is how it works but I want it in such a way that in one sitting when he is filling out the data on the second page (after filling the data on first page) on reverting back to the first page he should be able to see the data that he had filled out.
What concept can I use? I'm not sure view state will be helpful in this scenario.
You should look into using the Session State variable for storing his information over the entire session. If the user is logged in you should think about storing his information that he enters in a database and having a Boolean state of "ApplicationFinished" to check if he has finished it or not. Otherwise I would have a call on each page to retrieve information from the database that has already been added, so that he can fill out information at different sittings or all at once.
http://msdn.microsoft.com/en-us/library/ms178581.aspx
Session State may be too long term for you, and if that is the case do some research on ViewState. There are a lot of different ways to tackle a problem like this. It all depends on which technology will fit your needs the best.
http://msdn.microsoft.com/en-us/library/ms972976.aspx
Also, if you're using a tab system think about using the AJAX tabs so that the data will remain on the forms even while tabbing through the different tabs.
http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/
Well, if you are write the data on database, i guess the best (fast) workaround is to add a column named "completed" to the table the hold this informations. If the flag "completed" is not setted to 1, you load the database information and fills the page controls.
When you create a new record in the database, get the ID of the record and set it on Session. If the user gets back to the first page (previous page), you can recover the information ID and load the data.
As long as you are learning new things... add jquery to the list and leverage the JQuery Wizard Plug In. It will allow you to integrate your "10 page form" into a single unit, which can then be sub divided, routed and managed more easily. You can leverage AJAX to save each step, while offering built in navigation and validation methods.
I would suggest that you switch to using client-side javascript to control your tabs. That way your form data stays in the fields when you switch back and forth between tabs. You can use javascript buttons to guide the user from tab to tab.
I've done this using JQuery. I actually had 150 fields that needed to be captured (they were all required). I group like data on different tabs and then had buttons ('< Previous', 'Next >') which would activate different tabs.
When they are done, then display the 'Save' button.
This not be what you are looking for, but if your problem is that you want all of the input of a previously filled page to show up when a user navigates back to it, and you have already saved all that information, then you can try something like this:
HTML
<input type="text" id="yourID" name = "yourName" value = "<%=data%>"/>
Then all you need to do is set data to public in the code behind. Then to get the value for data just make a call to your database.
Make sure that you make data empty on the init call public string data = ""; or whatever type it is. This way if there is no info, then it will be blank, and if there is saved info, then it will be filled in.
You can also attempt to pass all the data through params in the url like so:
C#
Response.Redirect("webpage.aspx?data=" + data + "&data1=" + data1);
Or though javascript:
window.location = ("webpage.aspx?data=" + data + "&data1=" + data1);
To get the request do this:
if (Request.Params.AllKeys.Contains("data"))
{
data = Request.Params["data"];
}
This way is less ideal though if there is a lot of data being passed.