Crystal Report View page numbers - asp.net

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.

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.

Cross-page posting with target _blank leaves source page unfunctional

I'm trying to describe it in as few steps as possible:
I have Page1.aspx with lot of controls, and Preview and Save button among those. I also have Page2.aspx that is the redirection target of a Preview Button click.
Since I need all the controls selections from Page1 to draw a preview on Page2 the redirection is done with setting Preview's PostBackUrl.
I also must have preview shown on a new tab or window so I used onClientClick="aspnetForm.target='_blank'" for Preview button definition.
Save button-click callback, after storing data to a database does redirection to some Page0.aspx (initial list of reports - the subject of the code)
Preview button works fine - a preview renders in a new tab, but when I go to the old tab and click on Save, I see from debugger, that firstly Page2.aspx(?) and secondly Page1.aspx are loaded. Then all the data is stored in the db, but though Page0 redirection is executed Page1.aspx stays loaded in the browser.
I have no idea what processes are behind this. Could one who knows give me an insight? Or if you consider my approach impossible to implement give some idea how to do the same?
If it's of importance, everything on the Page1 is located in an update panel.
Thank you very much for replying
In ASP.NET there are basically zero (0) circumstances in which you will ever send form data from one page to another. Although what exactly you are trying to accomplish is vague, you can consider some of the following:
Isolate unique operations/systems to a single page. If you have something like a User Profile, don't have three different aspx pages; just use a single page for the user or admin to manage that data / functions. Postback events are your friend.
Understand the difference between ViewState and traditional form data. I'm guessing that if you're trying to post form data from one page to another, you probably don't understand the point of ViewState. Using a single page to maintain temporary data that the user is currently working with is a great use for ViewState. If you want the data to appear on another page then you need to consider the data from the previous page as final and thus should be saved to a database or some other medium.
These are just some general guidelines because there is no exact answer to your problem without saying something generic like "You're doing it wrong." I would recommend starting by never again trying to post form data from one aspx page to another.

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.

User friendly paging for report page type?

I have a report page that currently using a paging like this:
But my PM is asking me to implement a Google-like paging because he want that the user can interact with the page only by clicking and don't have to use their keyboard to input in the page number. But in my opinions, I don't think Google paging is suitable for a report page which contains many pages/records, and the users will not be able to quickly go to a page that outside the displayed range.
I'm thinking about combine both the paging which means it has the displayed range like Google paging and also a text box to quickly jump to a page but it may look messy right?
So I'm looking for someone that experienced in this to give me some advices.
Thanks a lot!
If (as your example) you have a report of 30 pages then googlesque paging won't help your users get to (say) page 21 from page 1 but will the users know that they need to go to page 21? If you do need to be able to jump to any given page then replace your markup above to use a drop-down list with auto-postback enabled and drop the Go button; no typing required and any-page navigation :-) Prev & Next might be user friendly too if end-to-end reading is a usual practice.

Are there any good examples of ajax paging?

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/

Resources