Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have a very big form with lots of calculations for the user. Almost all of the controls(Textboxs) are AutoPostBack . But if suppose I enter value in textbox with AutoPostBack On, the page reloads as it should, but takes time and after entering the value the cursor goes on another control... I write code on each textbax textchanged event and i uploaded my application on server it takes time to calculation..
Posted
Comments
Sergey Alexandrovich Kryukov 16-Sep-13 2:56am    
Right, it can be too slow. But why not doing those calculations on client side, without auto postback?
—SA
Dholakiya Ankit 16-Sep-13 3:00am    
:: Thumbs UUUp ::
Sergey Alexandrovich Kryukov 16-Sep-13 3:12am    
:-)
Sachin Mortale 16-Sep-13 3:03am    
can you please tell me how can i do that calculation on client side..
Sergey Alexandrovich Kryukov 16-Sep-13 3:15am    
What do you mean "how"? By writing JavaScript code. This is your calculations, so you should know better. You can handle onchange event the way you need. Any concerns? If you don't know enough of JavaScript, learn it. jQuery can be very helpful.
—SA

Another thing to watch out for, depending upon what you're currently doing:

If you put your text changes back in the same text box that has the text-change event then you are, in the general case, doing another text change: a potentially endless loop until and if you reach a constant value. This multiple execution can also slow things down (or lock the application, altogether).

Solution, should you now (or in the future) be posting your changes back to the original text source is to put a static flag in the handler to prevent it from running twice (although you do get two visits - but one just resets the flag and returns).
 
Share this answer
 
v2
Try JavaScript that's the best option. It not only fasten your process but also help u to prevent the round trip to the server.
-SG
 
Share this answer
 
1st divide your controls into user controls, just to avoid mixing up the logic. Put related controls in specific user controls.
Next put calculation logic using javascript within each user control and put the final calculated value in a hidden field. Expose the value as a readonly property from the user control. Put each user control in a separate UpdatePanel, to ensure the entire page doesn't posts back, just a specific UC only.

Not only will you be able to reduce the amount of postbacks, you will also clean up the page's own processing and introduce lots of modularity in the application.
 
Share this answer
 
hii Sachin,

Use Updatepanel to avoid autopostback to refresh page....and after calculation on first textbox write textbox2.focus() to point cursor on proper control might this information will help you...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900