Asp.Net Display message instead of loading image for long running process - asp.net

When i click on button need to display message instead of loading image for long running process.Need to show what is happening in my code behind.Like below stages
Collecting information from database..........
Generating PDF document..............
Sending e-Mail........
Done.
Note:No need to set default time for stages it need to take message from code behind and display.
Please send me any related links.
Thanks in advance.

Check out Easy incremental status updates for long requests

You could easily add a TextBox control and change the Text property by your code behind, in function of what you do.
For example:
private void Loading()
{
txtLoading.Text = "stage1.Collecting information from database";
// PUT CODE TO COLLECT INFORMATION FROM DATABASE HERE
txtLoading.Text += "\r\nstage2.Generating PDF document";
// PUT CODE TO GENERATE PDF DOCUMENT HERE
// ETC ETC
}
Hope it helps :)

Related

progress bar while creating excel file asp.net

I've got a ASP.net page that create an excel file using eeplus library (http://epplus.codeplex.com/). my problem is that I create a really big file. It take times to be done and showed to the client. I search a way to show a kind of progressbar of the creation.
for the moment, the client click and wait til the file is created, so I cant really showed something.
What you're trying to do is actually pretty complicated. You might just want to show a spinning wheel gif or something and save yourself the headache.
However, if you're feeling adventurous, read on.
To use a progress bar, you need to create a way to measure how much % complete your task is. This usually involves some kind of incrementer that gets measured against the total number of rows/column/whatever that you're creating. I don't know what language you're using, so here's some pseudo to help you out:
var totalRows = 100;
var processedRows = 0;
var progress = 0;
while( processedRows < totalRows ){
Process_A_Row();
processRows++;
progress = processedRows / totalRows;
StoreProgressSomewhereForPolling();
}
So there's your basic mechanism for tracking progress. On the client, you'll need to set up a way to poll the value of the progress variable. This gets messy because you'll quickly learn that you need a way to isolate the progress variable for every individual request. Its up to you how to implement this -- there are lots of ways to do it. One solution I saw stored the progress value in a static dictionary keyed by username so that it could be easily polled by the client with webmethods.
A quick solution would be to use the Ajax.NET UpdateProgress control. Just display a GIF that spins while the server is processing.

how to make the data show when i start typing

am working on a website using asp.net
but am new to this
i have information stored in database
and then in the form i have the following
code description description (ar)
these are colums of the table in the database
i want the info in the database to show wheni start typing
for example if i write "a" all the words that start with a should show
how can i do that?
and what should i write here
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
??????
Make event listener to your html text field, like
Do an ajax call to server method/action sending your input contents
Query database to get TOP(N) records, containing/starting with text you sent to server
Return strings/nothing to client side
If there are some results found show a tooltip, containing results
you should use a ui framework for this purpose, see this example on knockoutjs

Open print dialog for report from code

I am attempting to force open the print dialog so that all the user has to do is set the email address and press ok. I've found multiple tutorials on how to print a report to file or a printer without the print dialog, but that's not what I'm looking for.
Typically to email a report, the user displays the report, clicks the print icon in the tool bar, and then chooses email and sends it. I want to cut out the first two steps automatically.
This is one of my many attempts at doing this so far, but to no avail.
void emailInvoice()
{
Args args;
ReportRun rr;
Report rb;
PrintJobSettings pjs;
CustInvoiceJour record;
;
select record where record.RecId == 5637175089;
args = new Args("SalesInvoice");
args.record(record);
args.parmEnum(PrintCopyOriginal::OriginalPrint);
// Set report run properties
rr = new ReportRun(args,'');
rr.suppressReportIsEmptyMessage(true);
rr.query().interactive(false);
// set report properties
rb = rr.report();
rb.interactive(true);
// set print job settings
pjs = rr.printJobSettings();
pjs.fileName(strfmt("C:\\Users\\gbonzo\\Desktop\\%1.pdf", record.SalesId));
pjs.fitToPage(true);
// break the report info pages using the height of the current printer's paper
pjs.virtualPageHeight(-1);
// force PDF printing
pjs.format(PrintFormat::PDF);
pjs.setTarget(PrintMedium::Mail);
pjs.viewerType(ReportOutputUserType::PDF);
// lock the print job settings so can't be changed
// X++ code int the report may try to change the destination
// to the screen for example but this does not make
// sense when running a report here
pjs.lockDestinationProperties(true);
// Initialize the report
rr.init();
rr.run();
}
Thanks in advance for your help!
Have you tried to develop a RunBase standard dialog class (RunBaseBatchPrintable if you need to select the printer) that get all the dialog fields you need and from there, programatically run the report passing all the desired parameters? I'm prety sure it will work, and probably will left a cleaner code separating the report of the logic needed to the user interaction.
Read an example here:
http://waikeatng.blogspot.com.es/2010/10/using-runbasebatchprintable-class.html
You have to call the prompt() method of the ReportRun class before calling the run() method.
if (rr.prompt())
{
rr.run();
}
The prompt() method will show the print dialog. If you want it easier for your users you could use the SysMailer class, take a look to the quickSend() method.

Printing silently from Spring MVC/Jasper Application

This is very abstract question.
I'm working on a Spring MVC Web Application which has to deal with lot of invoice printing continuously. Currently When the invoice is saved, the spring controller delegates the invoice id to the jasper pdf generation service which prepares the pdf. After the pdf gets downloaded, the user manually prints it.
I need a way to print the invoice silently when the user saves the invoice.
Any ideas?
Since you are exporting to PDF it is possible. You need to add a JRPdfExporterParameter.PDF_JAVASCRIPT parameter to your JRPdfExporter instance with the value "this.print({bUI: true,bSilent: false,bShrinkToFit: true});". For Example:
protected static byte[] exportReportToPdf(JasperPrint jasperPrint) throws JRException{
JRPdfExporter exporter = new JRPdfExporter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print({bUI: true,bSilent: false,bShrinkToFit: true});");
exporter.exportReport();
return baos.toByteArray();
}
This actually adds the JavaScript to the PDF. When the PDF is opened it is ran, and will send it the print queue. It should be noted that this should be used sparingly as it is not generally considered to be nice to do this automatically for your users. When I have used it in an app, we had to buttons for each report. An Export button, that does not contain the JavaScript, and a Print button that did. That way users that wanted it to just print it would do so, and those that wanted a digital copy had that also.

How to show status of huge process to client(web)

Environment : ASP.NET, C#
I am writing a web program that will export 12 tables to another database. When the user click the "Export" button, the export process will get started. The thing is, I like to show some messages to client such as "preparing..., deleting old records..., exporting..., export completed."
But now, It is showing all status once 12 table are completed.
Please guide me how to do this.
Doing long processes like this is on a web page is probably not a good idea, you will need change the timeout settings on pages etc
Rather build a windows service that does all the work. You can then use the Page to initialte the process. The service could update some status that is read by the page. This way the page does very little work, ie initiate the process and poll for status updates. This can be done via simple jquery/ajax calls.
try this
put this on c#
and call ajavascript function per process
Page.RegisterClientScriptBlock("1","alert('add to table now')");
Use a javascript timer to periodically load content from a status page or service.
The timer is fairly simple:
setTimeout('checkProcessStatus()', waitTime);
The update itself depends on your choice of tech - for instance if using MVC and jQuery:
function checkProcessStatus() {
//dynamically add the html from the status page to <div id="taskStatusPanel"
$('#taskStatusPanel').load('export/status/' + taskId);
//set timer to call this again
setTimeout('checkProcessStatus()', waitTime);
}
Then the ExportController.Status action would return a simple view that displayed the HTML for the current status.

Resources