ASPX How to get the form initiated from OperatePage - actually should be the existing instance
-
GetTable is being kicked off from a background thread, it has no request context so has no server-side controls to access. Even if it did, you can't "push" data to the client that way, your server code isn't running inside the browser, it can't make changes to properties on server-side controls and have those instantly translated into DOM updates in the client html. Basically your architecture isn't going to work, you can't do what you're looking to do because it isn't compatible with how http works. You'll need a function on the client polling a method on the server via a timer, and have that method return the current state which you them show in the browser by updating the DOM from the javascript.
Yea, so much for hiring somebody to do it. So how can I get the lblMsg.text pushed to the web form so that the user can see the progress i.e. Doing Record# nnn???
-
Yea, so much for hiring somebody to do it. So how can I get the lblMsg.text pushed to the web form so that the user can see the progress i.e. Doing Record# nnn???
[WebMethod]
public static string GetProgress()
{
// just returning ticks as it is a number that constantly goes up
// you'll need to get your actual progressreturn DateTime.Now.Ticks.ToString();
}
<div id="progress">
</div>
<script type="text/javascript">
var t = window.setInterval(showProgress, 1000);
var p = $("#progress");function showProgress() { $.ajax({ type: "POST", url: "test.aspx/GetProgress", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { p.html('Progress: ' + data.d); // to cancel the polling // clearInterval(t); } }); }
</script>
-
I don't how you came up with that code, and it sort of looks like your a windows programmer trying to write a web form. In code block 1, not sure why your using sleep, you sort of want the code to run as fast as possible. In code block 2, you have a weird mixture of JQuery and Javascript. So I just figured out that you just want to show a progress image or something, or you just want to call the service and create a pause as if code is running or something. To show a progress, you just make a modal overlay using div, and just show and hide it using the client script. This is how client script via web service works, Introduction to using jQuery with Web Services[^]
I am not a web developer so please bear with me. 1. Sleep used to simulate long running process getting records from a large database from a web service and processing same in the server. 2. The java stuff was done by a developer that I hired who could not do what was needed. He is now gone. 3. I want to push the status / progress which may take 5-10 minutes and I want the user to see the progress i.e. Doing Record#=nn, Added=nn, etc. 4. I am happy with keeping the div showing all the time but the problem is that normally the web page does not get updated until the process is finished. For a long running process the user will give up after a minute unless he sees a change. 5. I am not sure what a modal div is but seems to imply that things wait until the modal div has completed something or the user hit a button. This is NOT what is needed.
-
[WebMethod]
public static string GetProgress()
{
// just returning ticks as it is a number that constantly goes up
// you'll need to get your actual progressreturn DateTime.Now.Ticks.ToString();
}
<div id="progress">
</div>
<script type="text/javascript">
var t = window.setInterval(showProgress, 1000);
var p = $("#progress");function showProgress() { $.ajax({ type: "POST", url: "test.aspx/GetProgress", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { p.html('Progress: ' + data.d); // to cancel the polling // clearInterval(t); } }); }
</script>
Thanks I need the actual count in the background server code which must use the web form to get paramenters, etc. How does the above fit in with the existing code? Do I remove it? or is this is combination with it?
-
Thanks I need the actual count in the background server code which must use the web form to get paramenters, etc. How does the above fit in with the existing code? Do I remove it? or is this is combination with it?
It depends what your gettable method is doing. I suspect you're trying to push html to the client which asp.net doesn't really support, the page has to be made in one go then sent to the client in one go, you can't do it in chunks (you can look at disabling buffering though, it might work, Response.Buffer = false). Chances are you're going to have to re-architect this and rather than generating the table in a background thread, have your javascript function keep calling a web method that returns the data 10 or 50 rows at a time then create the table html via javascript as each batch comes back. That way the page stays responsive and gradually loads. Doing it the other way and trying to write the table bit by bit might not work. Google for retrieving data via ajax, and building a table via ajax, you should get sample code of both.
-
It depends what your gettable method is doing. I suspect you're trying to push html to the client which asp.net doesn't really support, the page has to be made in one go then sent to the client in one go, you can't do it in chunks (you can look at disabling buffering though, it might work, Response.Buffer = false). Chances are you're going to have to re-architect this and rather than generating the table in a background thread, have your javascript function keep calling a web method that returns the data 10 or 50 rows at a time then create the table html via javascript as each batch comes back. That way the page stays responsive and gradually loads. Doing it the other way and trying to write the table bit by bit might not work. Google for retrieving data via ajax, and building a table via ajax, you should get sample code of both.
I understand that normally you get a server request and one page goes out and that is what I was really hoping to get around somehow. GetTable does just that. It gets a database table from a Web Service based on form controls and populates a grid. It also writes it to disk for potential downloads. I was hoping that this technology to update the lblMsg status could be used in other programs for a bunch of similar things. Putting in some java to keep requesting a chunk might work in this case but in our other programs it would not or at least not easily. In the other programs the code would be much more complex and could not be done in chunks since the processing id dependent upon what it did in the records prior. My thought is that since there are push technologies out there i.e. Chats do not need a user to push a button to get what other people enter, same for streaming that there must be a way of doing the same in my simple case. I have read about keeping sessions opened, etc. but since I am not a web developer I have a hard time getting my head around it. As an alternative I was thinking of changing the lblMsg.text to s variable lblMsg_text that perhaps the async methods could just use to populate the real lblMsg.txt via Java. Would there be a way for that to work. I would have to be an instantiated variable since multiple users could be using it.
-
I am not a web developer so please bear with me. 1. Sleep used to simulate long running process getting records from a large database from a web service and processing same in the server. 2. The java stuff was done by a developer that I hired who could not do what was needed. He is now gone. 3. I want to push the status / progress which may take 5-10 minutes and I want the user to see the progress i.e. Doing Record#=nn, Added=nn, etc. 4. I am happy with keeping the div showing all the time but the problem is that normally the web page does not get updated until the process is finished. For a long running process the user will give up after a minute unless he sees a change. 5. I am not sure what a modal div is but seems to imply that things wait until the modal div has completed something or the user hit a button. This is NOT what is needed.
Oh, I thought you were a programmer, I apologize for the mistake. As far as the progress goes, just depends on the UI design. I've been ditching the Modal Progress lately, for just swapping out the data input container for a progress container and then switching to a result container all in the same space. Sort of like tabs but with no tabs. Pushing the status to the progress container would be tricky. I'm trying to think of a way to do that. I guess I would write jquery to send data in small chunks, and display the results of that chunk, in a loop format. Sounds like you need some help in programming.
-
Oh, I thought you were a programmer, I apologize for the mistake. As far as the progress goes, just depends on the UI design. I've been ditching the Modal Progress lately, for just swapping out the data input container for a progress container and then switching to a result container all in the same space. Sort of like tabs but with no tabs. Pushing the status to the progress container would be tricky. I'm trying to think of a way to do that. I guess I would write jquery to send data in small chunks, and display the results of that chunk, in a loop format. Sounds like you need some help in programming.
I am a programmer but not for web apps. 40+ years of programming. I am not family with jQuery and have very basic Java knowledge. Need the techniques to be used. In vb.Net windows desktop you can bring up a modal screen or MessageBox but that stops everything. I do not want the progress indication to stop anything. The problem is not switching visible to invisible div's or controls but getting the data from / to controls and the 'running' form. I am not trying to populate the grid in periodically but the progress i.e. lblMsg.text = "Doing Record#=nnn"
-
I am a programmer but not for web apps. 40+ years of programming. I am not family with jQuery and have very basic Java knowledge. Need the techniques to be used. In vb.Net windows desktop you can bring up a modal screen or MessageBox but that stops everything. I do not want the progress indication to stop anything. The problem is not switching visible to invisible div's or controls but getting the data from / to controls and the 'running' form. I am not trying to populate the grid in periodically but the progress i.e. lblMsg.text = "Doing Record#=nnn"
I make windows applications, so I know that the messagebox stops the message pump running in the Windows OS. The thing here is, your working with HTTP protocol, and you have to obey the rules of it. On top of that, your working with HTML, which are elements, and not objects, sorry for the correction. So with the HTTP protocol, it's pretty much get and post, get a page, post a page back to the server. It would be a waste of time to keep submitting the form back for each piece of data transmitted, to show detailed progress. So you use a client script, that runs on the browser, to transmit each piece of data in the background, and change the DOM. The DOM is the collection of HTML that is downloaded from the server making up a web page. You can alter the HTML elements, delete, append, change text by manipulating the DOM using Javascript or JQuery. A working example here, that switches address input to progress, fetches the address, populates the textboxes, switches back to address input. I would experiment, or just write code that gets each line of data on your form, and run the AJAX call to web service in a loop, creating new HTML for each record processed. So instead a progress, they just see the data uploading, and new HTML records created. This would fool or give the illusion of progress, without having a bar or wheel. I suppose a fake progress sort of message box could be made with an HTML div that expands in witdh, colored green or blue. If you look at my Tip, I wrote a filmstrip that just loops, until the end is reached. The same principal could apply for your solution, in which 1 function just calls another function, until the end is reached. The primary function collects the data, the child function posts the data, and prints a result. If you need help on this, you can private message me. Display Advertising Filmstrip[^]
function Selected_Shipping_Address_Load(m_Data1) {
var panel\_CardInfo = $('\[id\*="\_panel\_MP\_CardInfo\_Container"\]'); var panel\_Progress = $('\[id\*="\_panel\_MP\_Progress\_Container"\]'); if (panel\_CardInfo.css('display') === 'inline-block') { panel\_CardInfo.css('display', 'none'); panel\_Progress.css('display', 'inline-block'); } else { panel\_CardInfo.css('display', 'none'); panel\_Progress.css(
-
I make windows applications, so I know that the messagebox stops the message pump running in the Windows OS. The thing here is, your working with HTTP protocol, and you have to obey the rules of it. On top of that, your working with HTML, which are elements, and not objects, sorry for the correction. So with the HTTP protocol, it's pretty much get and post, get a page, post a page back to the server. It would be a waste of time to keep submitting the form back for each piece of data transmitted, to show detailed progress. So you use a client script, that runs on the browser, to transmit each piece of data in the background, and change the DOM. The DOM is the collection of HTML that is downloaded from the server making up a web page. You can alter the HTML elements, delete, append, change text by manipulating the DOM using Javascript or JQuery. A working example here, that switches address input to progress, fetches the address, populates the textboxes, switches back to address input. I would experiment, or just write code that gets each line of data on your form, and run the AJAX call to web service in a loop, creating new HTML for each record processed. So instead a progress, they just see the data uploading, and new HTML records created. This would fool or give the illusion of progress, without having a bar or wheel. I suppose a fake progress sort of message box could be made with an HTML div that expands in witdh, colored green or blue. If you look at my Tip, I wrote a filmstrip that just loops, until the end is reached. The same principal could apply for your solution, in which 1 function just calls another function, until the end is reached. The primary function collects the data, the child function posts the data, and prints a result. If you need help on this, you can private message me. Display Advertising Filmstrip[^]
function Selected_Shipping_Address_Load(m_Data1) {
var panel\_CardInfo = $('\[id\*="\_panel\_MP\_CardInfo\_Container"\]'); var panel\_Progress = $('\[id\*="\_panel\_MP\_Progress\_Container"\]'); if (panel\_CardInfo.css('display') === 'inline-block') { panel\_CardInfo.css('display', 'none'); panel\_Progress.css('display', 'inline-block'); } else { panel\_CardInfo.css('display', 'none'); panel\_Progress.css(
Thanks let me play with that technique.