Results 1 to 18 of 18

Thread: [RESOLVED] [02/03] LoadingPage

  1. #1

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Resolved [RESOLVED] [02/03] LoadingPage

    hey guys,

    i need help in creating loading page. i have an asp.net application, in the process of inserting records into the database, i need a popup msgbox in which to show a message to ask the user to wait for processing. this popup msgbox should be closed automatically after the processing is done. my asp.net application currently work like this:

    1) user click on button
    2) a function started (it takes 5-10mins)
    3) datagrid shows the result

    in this stage, user will not know when is the processing is done. so i need to create a popup msgbox to display to the user that the process is running before the result is shown in the datagrid. any idea?

    i found some java code in the web, but it doesn't suit my needs. the java code i found shows redirecting to another page instead of a popup msgbox.
    *wink wink*

    _babyekc

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: [02/03] LoadingPage

    When you post back to the server (run your function) the whole page posts back - it does not leave some part of it on the client for you to work with when it returns. AJAX would be the solution i.e - click the button a message is dispalyed and the ajax call to the server is made - in the ajax response to the page you can hide your message and display the data...... If you haven't played with ajax yet google it, you'll probably find a code sample that suits your needs.

  3. #3

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    beside ajax, do javascript can do this for me?
    *wink wink*

    _babyekc

  4. #4
    Fanatic Member Valleysboy1978's Avatar
    Join Date
    Nov 2004
    Location
    Planet Xeoroaniar CC Posts:1,928,453,459,361
    Posts
    770

    Re: [02/03] LoadingPage

    Depends. If you are using any controls that are server-based (they have the runat="server" tag) then no, JavaScript will not help as the page will still post-back. AJAX will complete the processing without doing a complete postback, thus saving time.
    Life is one big rock tune

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] LoadingPage

    Since you need to show results after it is done, there are two ways.

    When the original data page is submitted, submit it to the processing page using AJAX and let it run. Meanwhile, show "Please wait..." or an animated GIF in a div on your page. The processing page should then return a chunk of data which you can use to display in your div as the results.

    The other way is to submit the data to a processing page which kicks off a thread to do the processing. It then redirects to a 'please wait' page which refreshes itself every x seconds while checking for a session variable. The thread function will manage the state of the execution using session variables.

  6. #6

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    so eventually i may have to go for ajax? okies thanks for the information. =)
    *wink wink*

    _babyekc

  7. #7
    Fanatic Member Valleysboy1978's Avatar
    Join Date
    Nov 2004
    Location
    Planet Xeoroaniar CC Posts:1,928,453,459,361
    Posts
    770

    Re: [02/03] LoadingPage

    Probably best, and it's a good skill to have
    Life is one big rock tune

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] LoadingPage

    Nothing like a buzzword to get you a good job these days.

  9. #9

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    im using asp.net 1.1. is there any ajax compatible with it?
    *wink wink*

    _babyekc

  10. #10

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    okies i found the ajax library for asp.net 1.1.

    but im too new to ajax. my code goes like this:
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Call Popup()
            If radStockUpdate.Checked = True Then
                grdStatus.Caption = "Stock Update"
                Call StockUpdate()
            End If
    
        End Sub
    
    ----------------------------------------------------------------------
    <Ajax.AjaxMethod()> _
        Private Sub Popup()
    
            Dim strPopup As String = "<script language='javascript'>" & _
                                     "window.open('/EIS/LoadingPage.aspx?', " & _
                                     "'CustomPopUp', 'width=600, height=600, scrollbars=yes, resizable=yes')" & _
                                     "</script>"
    
            Page.RegisterStartupScript("PopupScript", strPopup)
    
        End Sub
    ----------------------------------------------------------------------
    
        Private Sub StockUpdate()
       
             'Update DB
    
        End Sub
    This is the Button Click event, which i click the button and the page "Please wait..." popup while waiting the updating of db. But still it's not working, the page will only popup after the updating of db.

    p/s : i've included this Ajax.Utility.RegisterTypeForAjax(GetType(Download)) in the Page_Load event at the 1st place.


    This is the JavaScript code:
    Code:
    <script language="javascript">
    	
    		var iLoopCounter = 1;
    		var iMaxLoop = 5;
    		var iIntervalId;
    		
    		function BeginPageLoad() {
    			location.href = "<%= Request.QueryString("Page")%>";
    			iIntervalId = window.setInterval("iLoopCounter=UpdateProgress(iLoopCounter, iMaxLoop)", 500);
    		}
    	
    		function EndPageLoad() {
    			window.close();
    			window.clearInterval(iIntervalId);
    			Progress.innerText = "Page Loaded -- Not Transferring";
    		}
    	
    		function UpdateProgress(iCurrentLoopCounter, iMaximumLoops) {
    		
    			iCurrentLoopCounter += 1;
    			
    			if (iCurrentLoopCounter <= iMaximumLoops) {
    				Progress.innerText += ".";
    				return iCurrentLoopCounter;
    			}
    			else {
    				Progress.innerText = "";
    				return 1;
    			}
    		}
    		</script>
    <body bgColor="#efefff" MS_POSITIONING="GridLayout" onload="BeginPageLoad()" onunload="EndPageLoad()"></body>
    Any help is greatly appreciated.
    *wink wink*

    _babyekc

  11. #11

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    anyone has any idea?
    *wink wink*

    _babyekc

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] LoadingPage

    Why popup anything? Just display "wait..." in a DIV. Then kick off the processing. When the processing is done, show "done!"!

  13. #13

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    so if i want to use popup... the event wont fire?
    *wink wink*

    _babyekc

  14. #14
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] LoadingPage

    I'm not sure, as I only have a rough idea about your code. It is very possible that the popup is blocking the main window's execution thread, which is why I suggested that you keep everything in a single window. You do understand, right, that alert()s are modal?

  15. #15

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    its in the same window, im not calling the function at any other form/class.
    *wink wink*

    _babyekc

  16. #16
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] LoadingPage

    You are:
    Dim strPopup As String = "<script language='javascript'>" & _
    "window.open('/EIS/LoadingPage.aspx?', " & _
    "'CustomPopUp', 'width=600, height=600, scrollbars=yes, resizable=yes')" & _
    "</script>"

  17. #17

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: [02/03] LoadingPage

    oh i thought u were saying the StockUpdate() function. okies, im too new to ajax. could u supply me some code for it? for framework 1.1.
    *wink wink*

    _babyekc

  18. #18
    Lively Member
    Join Date
    Aug 2006
    Location
    india
    Posts
    88

    Re: [02/03] LoadingPage


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width