Hi all. Tried to do a search on this one, but didnt know exactly how to word it so I wasn't able to find much info on what I wanted to do.
Overview of what I'm trying to do.
Version: asp.net 1.1
I have a crystal report that takes a long time to run and impatient users click the submit button over and over mucking up the system.
I've been trying to create a "processing your request" type progress bar that will pretty much inform the user to chill out and let the report run its course. (I'm also going to disable the buttons when I get that far).
I've gotten the bar to run, but for the life of me cannot call the ProcessReport() from the javascript and its driving me nuts.
html_ShowElement('AjaxLoading'); // There's another function to show the element, thats not an issue, so I didnt include it //
window.setTimeout('$x("AjaxLoading").innerHTML = $x("AjaxLoading").innerHTML', 100); }
???? Here's where I'm hitting the ceiling. What do I call here to run the ProcessReport() c# function in the code behind?
I've tried __doPostBack and <% ProcessReport(); %> (which unfortunately runs the process as soon as it's encountered so thats not good) and neither have seemed to run it for some reason.
my Form info:
<form id="wwv_flow" action="wwv_flow.accept" method="post" name="wwv_flow" runat="server">
Thanks for the iinfo on the control and the Ajax info. I have no idea what that is yet, I've seen references to it all over but figured it was a paid for control.
Looking at the control I have one question before I try it. I think i've tried something similar to this, but not sure.
When the "process report" button is clicked, a crystal report is generated and saved to the server as a PDF. Then the process redirects the user to that file which loads into an adobe acrobat reader that is displayed outside of the browser (in browser display
is turned off).
So I'm not sure if this will work for what I'm trying.
Right now what happens is that the progress bar pops up when the button is clicked, but after the redirect I can't seem to get it to stop.
What I've thought to do is create the file, store the value in a hidden field and on the post back, if that field is populated, turn off the progress bar and then do a javascript redirect. Which, I would expect, would do the same thing.
Not sure how well that would work though, im not as familar with javascript, so not sure how well that would work.
I doubt if the control will work for that, as it works asynchroneously on a page object.
While the Page object is doing the server-side processing, the control is visible. As soon as the server-side processing is completed, the control is hidden.
You'd have to have to place it into the PDF doc that you are redirecting to. This might work however.
Instead of redirecting to the PDF doc, redirect to this dummy page which only contains an IFrame to display the PDF doc.
Here is an old .NET 1.1 function I wrote a while back which disables a Button after it is clicked (only if it passes client-side validation). The server-side code for the button will still run though and the button will re-enable after the postback completes.
It is overloaded to allow the passing of a message which will override the message that exists on the button. Here is the function:
Normally it does. That is why I came up with this solution awhile back. It will disable the button client-side after it is clicked (ONLY if client-side validation passes) but it will still fire the server-side button event. It will remain disabled until
the button's server side code completes and the page completes its post back.
Frank Phillp...
Member
125 Points
30 Posts
Javascript calling c# function
Sep 18, 2007 02:16 PM|LINK
Hi all. Tried to do a search on this one, but didnt know exactly how to word it so I wasn't able to find much info on what I wanted to do.
Overview of what I'm trying to do.
Version: asp.net 1.1
I have a crystal report that takes a long time to run and impatient users click the submit button over and over mucking up the system.
I've been trying to create a "processing your request" type progress bar that will pretty much inform the user to chill out and let the report run its course. (I'm also going to disable the buttons when I get that far).
I've gotten the bar to run, but for the life of me cannot call the ProcessReport() from the javascript and its driving me nuts.
Javascript:
function html_Submit_Progress(pThis)
{ if(pThis.nodeName=='INPUT') {
pThis.value='...Loading...' }
else {
pThis.innerHTML='...Loading...' };
html_ShowElement('AjaxLoading'); // There's another function to show the element, thats not an issue, so I didnt include it //
window.setTimeout('$x("AjaxLoading").innerHTML = $x("AjaxLoading").innerHTML', 100); }
???? Here's where I'm hitting the ceiling. What do I call here to run the ProcessReport() c# function in the code behind?
I've tried __doPostBack and <% ProcessReport(); %> (which unfortunately runs the process as soon as it's encountered so thats not good) and neither have seemed to run it for some reason.
my Form info:
<form id="wwv_flow" action="wwv_flow.accept" method="post" name="wwv_flow" runat="server">
Any help would be greatly appreciated.
Thanks
Frank
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: Javascript calling c# function
Sep 18, 2007 02:24 PM|LINK
There is really no way to do that, as client-side processing and server-side processing are 2 different things.
I posted this little control a while back that works asynchroneously and might help you out:
http://forums.asp.net/1108756/ShowPost.aspx
Or you might take a look here for an AJAX solution:
http://ajax.asp.net/docs/tutorials/PartialPageUpdateTutorials.aspx
NC...
JoshStodola
Star
13736 Points
3177 Posts
Re: Javascript calling c# function
Sep 18, 2007 03:57 PM|LINK
For the button that generates the report (in Page_Load):
Button1.Attributes.Add("onclick", "this.style.display = 'none'; alert('Hold your horses!');")Hope this helps! Please mark the helpful post(s) as Answer.
Frank Phillp...
Member
125 Points
30 Posts
Re: Javascript calling c# function
Sep 19, 2007 05:04 PM|LINK
NC,
Thanks for the iinfo on the control and the Ajax info. I have no idea what that is yet, I've seen references to it all over but figured it was a paid for control.
I'll let you know how it works out.
Thanks again,
Frank
Frank Phillp...
Member
125 Points
30 Posts
Re: Javascript calling c# function
Sep 19, 2007 05:27 PM|LINK
Looking at the control I have one question before I try it. I think i've tried something similar to this, but not sure.
When the "process report" button is clicked, a crystal report is generated and saved to the server as a PDF. Then the process redirects the user to that file which loads into an adobe acrobat reader that is displayed outside of the browser (in browser display is turned off).
So I'm not sure if this will work for what I'm trying.
Right now what happens is that the progress bar pops up when the button is clicked, but after the redirect I can't seem to get it to stop.
What I've thought to do is create the file, store the value in a hidden field and on the post back, if that field is populated, turn off the progress bar and then do a javascript redirect. Which, I would expect, would do the same thing.
Not sure how well that would work though, im not as familar with javascript, so not sure how well that would work.
Frank
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: Javascript calling c# function
Sep 19, 2007 06:08 PM|LINK
I doubt if the control will work for that, as it works asynchroneously on a page object.
While the Page object is doing the server-side processing, the control is visible. As soon as the server-side processing is completed, the control is hidden.
You'd have to have to place it into the PDF doc that you are redirecting to. This might work however.
Instead of redirecting to the PDF doc, redirect to this dummy page which only contains an IFrame to display the PDF doc.
Call by:
Response.Redirect("PdfDisplayer.aspx?PdfDoc=" + pdfDocUrl);
///////////////////////////
// aspx file:
///////////////////////////
<%@ Page language="c#" Codebehind="PdfDisplayer.aspx.cs" AutoEventWireup="false" Inherits="Tester.PdfDisplayer" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>PDF Displayer</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<base target="_self">
</HEAD>
<body bottommargin="0" topmargin="0">
<form id="Form1" method="post" runat="server">
<iframe id="displayIFrame" frameborder="0" height="100%" runat="server" src="" width="100%">
</iframe>
</form>
</body>
</HTML>
///////////////////////////
// aspx.cs file:
///////////////////////////
protected System.Web.UI.HtmlControls.HtmlGenericControl displayIFrame;
private void Page_Load(object sender, System.EventArgs e)
{
string frameSource = this.Request["PdfDoc"];
this.displayIFrame.Attributes.Add("src", frameSource);
}
NC...
jamezw
Participant
1211 Points
190 Posts
Re: Javascript calling c# function
Sep 19, 2007 07:30 PM|LINK
Here is an old .NET 1.1 function I wrote a while back which disables a Button after it is clicked (only if it passes client-side validation). The server-side code for the button will still run though and the button will re-enable after the postback completes. It is overloaded to allow the passing of a message which will override the message that exists on the button. Here is the function:
private void DisableButtonOnClientClick(ref Button control, string message) { control.Attributes["onclick"] = "if(typeof(Page_ClientValidate)=='undefined'||(typeof(Page_ClientValidate)=='function'&&Page_ClientValidate())){this.disabled=true;" + (message != null ? "this.value='" + message + "';" : "") + GetPostBackEventReference(control) + ";return false;}"; } private void DisableButtonOnClientClick(ref Button control) { DisableButtonOnClientClick(ref control, null); }Just call this function on each page load for any button you want it attached to like this:
JoshStodola
Star
13736 Points
3177 Posts
Re: Javascript calling c# function
Sep 19, 2007 07:41 PM|LINK
Doesn't disabling the button cause the server-side event handler to not fire?
jamezw
Participant
1211 Points
190 Posts
Re: Javascript calling c# function
Sep 19, 2007 07:45 PM|LINK
Normally it does. That is why I came up with this solution awhile back. It will disable the button client-side after it is clicked (ONLY if client-side validation passes) but it will still fire the server-side button event. It will remain disabled until the button's server side code completes and the page completes its post back.
jamezw
Participant
1211 Points
190 Posts
Re: Javascript calling c# function
Sep 19, 2007 07:48 PM|LINK
I wrote a similar function in .NET 2.0 which accounts for validation groups. If someone wants it I will dig it up and post it as well.