Are there any good examples of ajax paging? - asp.net

i have a page that displays large datasets into html tables. how can i add paging without having to refresh the whole page each time i change pages

Basically you just need a page for your form submission, and given the search criteria and a page number, it just returns the next page, preferably as a json result, so you can just change the cells in the current table, which will be faster to render.
It appears this is an example of what you want:
http://encosia.com/2008/08/20/easily-build-powerful-client-side-ajax-paging-using-jquery/

Related

ASP.NET: Creating multiple printable pages and print them with one click

I want to achieve the following: create a number of instances of the same web page, each of the the pages displaying slighty different data (like customer name, address, ...). These pages should be printable with as less effort for the user as possible. The problem is that if you call the javascript print-directive on every page, the user would get a ton of the PrintDialogs.
One solution to solve this problem would be to create those print pages dynamically during runtime and put them all on one page, separated by page breaks (so the user would only have to confirm the print dialog once). This solution has the huge problem that I can't use the Visual Studio designer to put my page together.
Another possible solution would be to build the template of the page in the designer, dynamically fill in the customer-specific data into the corresponding controls for every page, and then somehow chain all the resulting pages together to one long page; again separated by page breaks. But I dont really know how to do that....I tried to use the Render() event, get the HTMl code and then duplicate it, but I didnt have much success with it.
So, any guidance for the Render() approach or any other solutions would be very welcome!
Is your data in any form of list? Can it be put into one? Not necessarily all of it, but an ID per desired page, or something similar? Sufficiently that it could drive a data-bound control?
You could use a Repeater control on your page to build out your "pages" according to a template. Page breaks could be achieved with CSS styles. Then you'd have just one (long) page you had to print.
You could even make your "page" a UserControl to make data-driven variations in rendering easier to organize.

Is this possible in ASP.NET? Change data on a page without reloading page

I want a table in the page to be filled with the data that corresponds with a picture on the page. The user has to click the picture that he wants more information about. The way i have done this is making the images into image-Buttons, Make the button store a session variable and redirect back to the same page, then the session variable is read and used to fill the table. Is it possible to get the same results without reloading the page?
From your question I can guess that you're using webforms.
Yes, it's possible in ASP.NET, take a look at UpdatePanel control, it does exactly what you want.

How to keep a rendered page for later usage (to resend it later)

I have an asp.net application with a search page, with criteria and result display on the same page. I want to keep a copy of the populated search page to redistribute it later to the same user, upon the button click on another page. It's kind of a "return to search" button. How can I do that?
Here is some context:
The search criteria is made up of some basic controls, and the results are then (after postback) displayed in a GridView. I also have a master page. Simple as that.
Now consider the following scenario: The user can investigate the results by clicking links that show detail pages, and can drill down over quite many detail pages with associated data. If he/she wants to get back to the search results he/she needs to click the back button of the browser quite many times.
I would like to provide a "Back to search" button on the master page that allows to return to the populated search page with one click.
Note:
I can not use the browser history in any way because it must work also when the user opened one of the detail views in another tab.
I have seen Keeping the Viewstate persistent and retrieve it on demand but it hope there is an easier solution because my grid is paginated and I have also more than one search page, where I would like to return to just the last one used.
Thanks, Marcel
I can offer some logical ways to resolve this problem, without using specialized asp.net features if they exist:
1) Is there some way to save the search string in GET request? So you can save it some way between moving through pages?
2) Another way is caching search pattern (with all filters or what you need there) somewhere - in database, for example and contain some key in get request, which would point on this pattern.

Paging search results with asp.net MVC

I have a situation that I couldn't find a solution for through my searches on here. Here is the scenario:
I have a search form with 2 required fields and multiple optional ones. The form posts to an action method that determines which fields are selected and builds a List<> of objects that match the search criteria. I then pass that List<> to the view for display.
This issue I am running into involves how paging is typically done with asp.net mvc. For past projects I have used a custom Html helper that creates links which include the query parameters as well as a "page" parameter. It then uses a GET request and the .Take().Skip() format.
I've hit a wall on this project as I can't use a GET request for the search criteria and I can't figure out a way to keep the List<> in memory to do the usual "page" parameter trick.
I thought about storing the List<> in the session but the objects and the list could be very large.
I would think this is a popular issue with advanced search forms but I can't seem to find a good solution. Any help would be appreciated. Thanks!
How about cacheing the search result object and giving it a unique key. You would then have your paging links reference that unique (SearchID) and have your action look for that object, pull it from cache and Skip/Take from there.
This will not rebuild the object for every request, making page loading much faster and reducing strain on your database/application.
Here is a article about cacheing:
https://web.archive.org/web/20211020111559/https://aspnet.4guysfromrolla.com/articles/100902-1.aspx
Here is a video about cacheing:
http://www.asp.net/learn/Videos/video-6206.aspx
Note: Be sure you specify expiration date on the cached object.
If I understand properly, you only want to load the search results one time, and then page through them.
Have you looked into any jQuery paging functionality? You can just dump the entire list to the page and use JavaScript to handle the paging (and sorting if you like).
An example can be found at http://beckelman.net/demos/jqueryTableSorterConPaging/default.aspx
Put everything in the same form: the required fields, the optional fields, the page links.
Two possibilities:
Use submit buttons or images instead of anchor tags for the page links each having a different name (e.g. page1, page2, ...): this will allow you to get the desired page when the form is submitted.
Put a hidden field inside your form. Then add a javascript click handler to any of the page anchors. This handler will update the value of the hidden field with the page, submit the form and cancel the event.
So clicking on any of the pager links will submit the form with all the data you need to build the list and pager links.

Crystal Report View page numbers

I am using the Crystal Report Viewer in an ASP.NET application. On the viewer it displays the page numbers along the lines of '1 / 1+' where the 1+ is dynamically calculated. I would like it to display the correct total number of pages from the start rather than 1+. Is there a way to do this?
I think a number of the examples online recommend that you navigate to the last page and then back to the first, but I don't think this is a good way of handling it. I have yet to have the need to do this for any of my projects so I haven't had to try to find a work around yet.
Edit-
Ok, after looking at this just now I realized that if you add the "Page N of M" special field it does the dynamic calculation at runtime. In my testing it will do the dynamic calculation even if you choose to suppress the field by checking the suppress box in the field properties. Granted the dynamic calculation might be slower for larger reports, this is probably just as good as programmatically navigating to the last page and back to the first. Hope this helps.
Crystal Report's Page engine renders sections the first page as quickly as possible to give the perception of performance. You may have noticed field values rendering quickly, with place holders (spaces) for subreports and other resource-intensive objects. As the Rendering engine finishes processing these objects, the place holders are replace with values.
The page numbering situation is similar. The navigation control will initially read '1+', but will increment as the Page engine renders additional pages. When the whole report is rendered, the navigation control and the Page N of M field will display the total page count.
If you insist on altering the user-experience, you may be able to use the Viewer's BeforeRender or BeforeRenderContent event to set HasPageNavigationButtons=False and AfterRender or AfterRenderContent event to HasPageNavigationButtons=True.
I'm not certain that you will be able to do something similar with the Page-N-of-M field.
You have a property called TotalPageCount. If you put that in your report will show the page numbers correctly.
For example, I have a formula field like ToText(PageNumber,0) + "/" + ToText(TotalPageCount,0) to show current page from total pages.

Resources