Read web.config file in jQuery

In my web.config file there is one key that I need to access to perform some operations on my page. I want to do it using Javascript or jQuery. Below is the sample of key that I’ve in web.config file.

Web.config:

<configuration>
<appSettings>
<add key=”OperationType” value=”ADD” />
</appSettings>
</configuration>

 

Code:

<head runat=”server”>
<title></title>
http://code.jquery.com/jquery-1.9.1.js

$(document).ready(function () {
$(‘#btnCompute’).on(‘click’, function () {
var firstNumber = parseFloat($(‘#txtFirstNumber’).val());
var secondNumber = parseFloat($(‘#txtSecondNumber’).val());
var operationType = ”;
switch (operationType) {
case ‘ADD’: alert(firstNumber + secondNumber); break;
case ‘SUB’: alert(firstNumber – secondNumber); break;
case ‘MUL’: alert(firstNumber * secondNumber); break;
case ‘DIV’: alert(firstNumber / secondNumber); break;
}
});
});

</head>
<body>
<form id=”form1″ runat=”server”>
First Number:
<input type=”text” id=”txtFirstNumber” />
<br />
Second Number:
<input type=”text” id=”txtSecondNumber” />
<br />
<input type=”button” name=”Compute” value=”Compute” id=”btnCompute” />
</form>
</body>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s