Solved

How to accelerate __doPostBack?

Posted on 2009-05-14
9
826 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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 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…

776 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