This is somewhat related to my previous printing question re: remote printing, which I resolved with help here at work. This new situation likely has a simple answer as well, but I have yet to discover it.
To simplify, I have two webpages written in ASP.NET with C# codebehind, which we can call page1.aspx and page2.aspx.
The first page, page1.aspx, is a simple search tool that opens a database and returns a list of reports matching the search criteria into a gridview. The second page, page2.aspx, displays a report in the web browser, given the report ID as a query variable (which I have working). This page is also pre-formatted to be printer friendly.
On page1.aspx, in my gridview, I have two buttons for each row labeled "View" and "Print". The "View" button will retrieve the appropriate order number for the corresponding row, and page2.aspx will load the report based on the order number (again passed as a query variable).
For the "Print" button, however, I would like to print. That is, when the user clicks the button, instead of the page loading onto the screen, I would like for the Print dialog to pop up and allow the user to print the report directly to the printer (since they are able to view the report using the separate button if they should so desire).
I would load page2 into an iframe, probably separately and have the page call a JavaScript print when loaded, or call focus on the iframe and then print on the same object.
You could load the page with a new call, or just load it when page1 loads in the background.
You would, of course, make the iframe hidden from view.
Related
I am using Active Reports in C#, and one option we present the users with is to print to a tray where the paper is White/Pink alternating.
Is there a printing method by which I can programatically cause each page to print twice, yet still collate correctly?
Edit:
My intended result is the following pattern:
Page one (white)
Page one (pink)
Page two (white)
Page two (pink)
Page one (white)
Page one (pink)
Page two (white)
Page two (pink)
Thus, each page is duplicated every time it prints.
Currently, I must disable collating and then print double the number of copies the user is asking for. However, the user must then manually assemble the documents.
Thanks for any help!
I see. So your report is by definition has to be duplicated on White and Pink and this duplication needs to be repeated based on users number of copies.
If you are using Page Reports you can design two page templates one for each "page color", use a master page to share the design elements of the page. You can also control that the pink pages is not visible in the viewer and are print only.
If you are using Section Reports, you would have to manage the duplication manually in your code. The Document class has a pages collection that you can manipulate, copying the page and inserting it into another location. Before printing you would need to copy p1 and p2 and insert them at the end, your report would now have four pages p1W, p1P, p2W, p2P. if the user prints multiple copies with collation on, everything should come out OK.
http://arhelp.grapecity.com/webhelp/AR10/index.html#GrapeCity.ActiveReports.Document.v10~GrapeCity.ActiveReports.Document.Section.PagesCollection~Add.html
hope this helps.
http://activereports.grapecity.com
I have a page on which user select a date range and submit the form. I am picking data as per date range and then binding it to the gridview. Since I have to also generate pdf just after binding I am using response.write to write the generated pdf file to the user. But the problem is that the gridview never changes. The moment I stops execution after gridbind(return;), the gridview binds properly. After struggling for some time i found out it is happining due to response.write and response.end statement which is used for writing the file.
My question is how to do these two task back to back? so that when user submit the form he sees the gridview with all data and also the file gets downloaded.
right now after gridbinding I generate 1 more link to the generated pdf but the client wants that it should be done in one go instead of 2 .
you can achieve this using two ways
show your data to user and set interval in javascript lets say wait for 1 min and then postback page to download PDF.
(RECOMMENDED)create another page say FileDownloader.aspx and open that page in new window using javascript. you can share your data between pages using session, disk, db whatever suits you best.
First off, I have managed to create a web application where my dynamically created user controls are recreated and repopulated with the correct information upon postback. I am not sure what my problem is, but i hope that you will be able to help me figure it out based on my situation:
On my page i enter the number of controls to be created into a hardcoded textbox (its on the aspx page) and click the okay butten. This in turn, creates the specified number of user controls dynamically using c# in the background.
So far the desired number of dynamic controls are in a table on the page.
Next...
I have 1 textbox and 4 dropboxes on each dynamic user control. When i type a company name into the textbox field and press enter or click away (on text changed event) it autoposts back and the textbox retains the company name that i have typed in.
Based on this string the dropboxes are populated from the database. Now when i select the desired items from the dropboxes and click on the save button (located outside of the dynamic controls, on the page) it does an insert to the database, but it turns out that upon this postback the indexes from the dropboxes have been reset and the wrong values get inserted.
The following pictures show firstly, how it should be and then how it is.
Basically the company name remains in the textbox of the dynamic control, but the information i choose from the dropbox resets to the first index.
It's hard to tell what happend without code, but this is a common mistake:
If you fill/create the dropdownlist controls in the page load event and you post back, the code will refill/recreate the controls. That's why you have to use something like If(!IsPostBack) in your page load event. Otherwise it will execute that code everytime you do a postback and actually just want to execute the code in your event handler for that button.
If you're dynamically creating the controls, make sure to do that in the Page_Init event. Dynamic controls have to be recreated on every postback. Their state is restored after the Page_Init (if it is a postback), so make sure to only set their values in Page_Load if you want to overwrite them.
I have an ASP.NET page where at the top of the page is a search box. There are 2 text boxes - one is an autocomplete extender for the Name on a database, and one is just inputting the ID.
The page features DetailsViews and GridViews primarily, and even when no account has been searched for, these display blank data which is not ideal. I sort of fixed this by using if (IsPostBack), encasing the elements in a placeholder and setting it to visible only if the page ispostback. But this doesn't cover if the user types in an incorrect ID.
Also, some accounts have huge amounts of data inside the GridView's. I had an issue where because I have no way of detecting when a data source's rows has changed, I end up binding whenever the page loads (Page_Load method). I've come to realise this is simply very bad - there are lots of times when the user can click various things in the page and have the page postback, and it takes an eternity to load each time I click something for accounts with lots of data.
Anyway, my question is essentially two-fold but I have a feeling the solution will be similar:
1: How can I detect when there are no accounts returned when searching, and disable the Grids/Detailsviews and show an error message?
2: How can I figure out when the user searches for another account and only rebind the grids after that has happened?
Thanks
This method is very ugly but it'll get the work done.
1) To Check whether there are no records; after the AutoComplete Extenders Webservice is called if no record is returned put some value in Session like
Session["NoData"]=true;
if Records are found then;
Session["NoData"]=false;
after the webservice is called do ajax request to check that session & on the basis of value do what you want.
2) You can achieve this also by following the above option.
Question:-
Page is a typical search page with few filters on it. When search for records based on filters, it shows result in Gridview. From grid view records, user can click on any record to see the details which takes the focus on new page.
Its working fine so far.
Now when user comes back from details page to search page. I am loosing selected filters values and no result in grid view.
How can i display selected filters and its results in gridview when user is coming back on search page? Any example etc.?
FYI, I am using sessions to pass parameters to the ObjectDatasource.
Store the search parameters in either a cookie or a session variable. When the user returns to the search screen, use those parameters.
If you're losing the values when you return to the search page, I assume your having the user navigate to the search page via a link, menu, etc.? In this case when the URL is loaded in the browser the search page loads for the first time (expected behavior).
You have a few options to persist the information:
1. Session: When the initial search form is filled out and the page posts back, persist/store the form values in session. Then modify the page such that it looks for those session values on initial load and binds the grid. This would allow the values to persist.
Loose Example:
protected void btnSearchButton_Click(object sender, EventArgs e)
{
//store the values of the form in session
}
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
//check if the values are in session.
//If so, remove them and use them to bind the grid.
}
}
The only issue with the above is that you will lose client-state in your grid, so if the grid has paging, etc. and the user was on page 4 originally, when the above binds it'll be back on page 1. You could get around this by also storing state information in session when the user clicks a link in the grid (assuming the grid causes a postback and not a direct client-side navigation to the details page). You could store page #, sort column, etc. and apply these when the user returns.
2. History/Javascript: If the navigation structure of your search -> details pages is such that you have a 'back to search' link on the details page, and you are confident that the only time the details page is loaded is through search -> details, then you could rely on javascript to step back one step in history. I believe the browser would then retain the state of the previous page (the search page) and allow the user to continue using it.
Loose Example (details page markup):
Return to Search Page
or
Return to Search Page
The above is untested but in theory may work. It would allow the user to click the link, or use the back button in their browser to the same effect. Again it would only work in theory if you have a very controlled workflow where you can guarantee the person arrived at the details page from the search page.
Just some ideas...