Parse JSON data using JavaScript Method in ASP.Net Page
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="json.aspx.cs"
Inherits="json"
%>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
>
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function jsondata()
{
var JSONObject= {
"name":"John
Johnson",
"street":"Oslo
West 555",
"age":33,
"phone":"555
1234567"};
document.getElementById("name").innerHTML=JSONObject.name
document.getElementById("age").innerHTML=JSONObject.age
document.getElementById("street").innerHTML=JSONObject.street
document.getElementById("phone").innerHTML=JSONObject.phone
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p id="name"></p>
<p id="age"></p>
<p id="street"></p>
<p id="phone"></p>
<input id="Button1"
type="button"
value="button"
onclick="jsondata()"
/>
</div>
</form>
</body>
</html>
No comments:
Post a Comment