how to get database values from sql server to the JavaScript function

Posted by Shreedar under ASP.NET on 10/30/2015 | Points: 10 | Views : 765 | Status : [Member] | Replies : 5
I have salary table inbsql server.
In asp.net I need to calculate total salary with in the buttonclick where onclick will call a javascript function like below.
function(int bonusSalary, int totalSalary)
{

var totalSalary= bonusSalary+majorSalary;
textbox.text=totalSalary;
}

Here bonusSalary and majorSalary should come from sql server salary table

Regards

Sridhar Thota.
www.dotnet-sridhar.blogspot.com



Responses

Posted by: Rajnilari2015 on: 10/30/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
You can get it done through AJAX .The rest looks fine.
Also you can fire a LINQ/LAMBDA and pass it to your AJAX function .
Hope this helps

--
Thanks & Regards,
RNA Team

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shreedar on: 10/30/2015 [Member] Starter | Points: 25

Up
0
Down
Hi Raj.

How to get values from table and pass those values to JavaScript function.

Regards

Sridhar Thota.
www.dotnet-sridhar.blogspot.com

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajnilari2015 on: 10/30/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
You can also have a look at my article http://beyondrelational.com/modules/2/blogs/80/posts/10676/crud-operation-using-javascript-and-sql-server-2008.aspx but I will never recommend this approach. It is just for the sake of knowledge I have shared.A better option is to use AJAX instead.
Hope this will be helpful

--
Thanks & Regards,
RNA Team

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajnilari2015 on: 10/30/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
B/T that, what happen to your basic programs (http://www.dotnetfunda.com/forums/show/20734/can-any-one-help-me-for-these-basic-programs ) ?.



--
Thanks & Regards,
RNA Team

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhupentiwari on: 11/9/2015 [Member] Starter | Points: 25

Up
-1
Down
Use Below code to pass values from code behind to your javascript.

 ScriptManager.RegisterStartupScript(this, GetType(), "myFunction", "CalulateSalary(" + bonusSalary+ "," + majorSalary + ");", true);


Please let me know if you are still facing issues



Thanks n Regards
Bhupendra Tiwari

Shreedar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response