I have to perform a calculation compaired to a matrix price list and do a Sales Tax (VAT) calculation, both the TAx info and the price matrix are stored in a database, but basically I will have a text box and when the amount is changed it will need to update
some information on the page.
As far as I can see I have two options,
1, I could send the information to the view and store in a hidden table, and when needed build a JQuery object and use that to do the calculations and append the information to the relavent areas
or
2, use ajax and send some information to a controller do the calcualtions a return a model and somehow (I assume Json as I have never used it) and update the page
however which is better or which is more standard, also will there be any delays, and is there a way that if they change 1 textbox and it has to do the calculation I have have that run and the user can change another textbox and the repeat happen?
The calculation is in an area where you need to sign in, but to have permission to use the form you would have permission to change the informaton anyway, and the information is on;y used to enhance the user experience its not stored in any way.
My issue now is actually the caluclation may change depending on the user so I will have to look into how to set that up.
I don't see here that the calculation is too confidential.
If you want to do the calculation as the value changes in the text box, I don't prefer to use, server side calculation, in this case, becuase, it is not a good idea, to send multiple request to server to fetch the same values.
Store the Tax info and Price matrix in hidden variables, and perform the calculation, using jQuery/javascript.
Hope this helps.
Don't forget to "Mark As Answer" if a post helps you.
EnenDaveyBoy
Participant
1465 Points
1146 Posts
Calculations on the fly quick question
Jun 16, 2012 12:24 AM|LINK
Hi
I have to perform a calculation compaired to a matrix price list and do a Sales Tax (VAT) calculation, both the TAx info and the price matrix are stored in a database, but basically I will have a text box and when the amount is changed it will need to update some information on the page.
As far as I can see I have two options,
1, I could send the information to the view and store in a hidden table, and when needed build a JQuery object and use that to do the calculations and append the information to the relavent areas
or
2, use ajax and send some information to a controller do the calcualtions a return a model and somehow (I assume Json as I have never used it) and update the page
however which is better or which is more standard, also will there be any delays, and is there a way that if they change 1 textbox and it has to do the calculation I have have that run and the user can change another textbox and the repeat happen?
CPrakash82
All-Star
18270 Points
2839 Posts
Re: Calculations on the fly quick question
Jun 16, 2012 12:56 AM|LINK
Is your calculation confidential? if not then yes you should always do at client side using jquery.
Thanks,
EnenDaveyBoy
Participant
1465 Points
1146 Posts
Re: Calculations on the fly quick question
Jun 16, 2012 07:04 PM|LINK
The calculation is in an area where you need to sign in, but to have permission to use the form you would have permission to change the informaton anyway, and the information is on;y used to enhance the user experience its not stored in any way.
My issue now is actually the caluclation may change depending on the user so I will have to look into how to set that up.
Thanks
CPrakash82
All-Star
18270 Points
2839 Posts
Re: Calculations on the fly quick question
Jun 16, 2012 08:14 PM|LINK
If it is user specific then it is always better to do it on server side. Below resources will help you.
http://msdn.microsoft.com/en-us/magazine/hh288075.aspx
http://stackoverflow.com/questions/677974/view-does-not-display-updated-values-asp-net-mvc
Thanks,
abdu292
Participant
1553 Points
371 Posts
Re: Calculations on the fly quick question
Jun 17, 2012 01:30 AM|LINK
I don't see here that the calculation is too confidential.
If you want to do the calculation as the value changes in the text box, I don't prefer to use, server side calculation, in this case, becuase, it is not a good idea, to send multiple request to server to fetch the same values.
Store the Tax info and Price matrix in hidden variables, and perform the calculation, using jQuery/javascript.
Hope this helps.
With best regards,