Solved

How to accelerate __doPostBack?

Posted on 2009-05-14
9
830 Views
Last Modified: 2012-05-07
Hi, we uses __doPostBack in our application we feel it's too slow , is there any way to accelerate it?
The following is a JS code example from our application:
function CallServerFunction(command,arg) 
    { 
        var hiddenID = 'HiddenField1';
        var hiddenField = document.getElementById(hiddenID); 
        hiddenField.value = command + "," + arg; 
        __doPostBack(hiddenID,arg)     
    }

Open in new window

0
Comment
Question by:Abdu_Allah
  • 4
  • 4
9 Comments
 
LVL 10

Assisted Solution

by:bugada
bugada earned 100 total points
ID: 24384850
A post back will reload the whole page. It also posts all the view state data with it which means more traffic. Are you sure you need it? Or maybe a simple ajax call can do the job?
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 24384962
As you can see from the code, we use __doPostBack function to send a value to a server side code to act based on that value. Is there any faster alternative?
0
 
LVL 9

Expert Comment

by:cdaly33
ID: 24385911
If you could include a javascript utility like jquery then you can pass the hidden field value to an asp.net pagemethod.  See the link below for how to set it up.
http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 3

Author Comment

by:Abdu_Allah
ID: 24386518
jquery is not in our plan.
0
 
LVL 9

Expert Comment

by:cdaly33
ID: 24386578
Can you use a standard Asp.net pagemethod call?
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 24386618
What is  standard Asp.net pagemethod call?
0
 
LVL 9

Accepted Solution

by:
cdaly33 earned 400 total points
ID: 24387249
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 24388157
It's a good idea but is it faster than __doPostBack() function? if so why?
0
 
LVL 9

Assisted Solution

by:cdaly33
cdaly33 earned 400 total points
ID: 24388934
It's faster because it doesn't have to send and retrieve all of the forms data.  It will only send and receive what is necessary for the function call.  A postback will cause the browser to rerender the entire form where as a pagemethod will only affect the fields that you want it to affect.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question