JSON Example
This page shows examples of messages formatted using JSON (JavaScript Object
Notation).
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup
Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages
such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
The same text expressed as XML:
<!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<glossary><title>example glossary</title>
<GlossDiv><title>S</title>
<GlossList>
<GlossEntry ID="SGML" SortAs="SGML">
<GlossTerm>Standard Generalized Markup Language</GlossTerm>
<Acronym>SGML</Acronym>
<Abbrev>ISO 8879:1986</Abbrev>
<GlossDef>
<para>A meta-markup language, used to create markup
languages such as DocBook.</para>
<GlossSeeAlso OtherTerm="GML">
<GlossSeeAlso OtherTerm="XML">
</GlossDef>
<GlossSee OtherTerm="markup">
</GlossEntry>
</GlossList>
</GlossDiv>
</glossary>
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
The same text expressed as XML:
<menu id="file" value="File">
<popup>
<menuitem value="New" onclick="CreateNewDoc()" />
<menuitem value="Open" onclick="OpenDoc()" />
<menuitem value="Close" onclick="CloseDoc()" />
</popup>
</menu>
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/[Link]",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "[Link] = ([Link] / 100) * 90;"
}
}}
The same text expressed as XML:
<widget>
<debug>on</debug>
<window title="Sample Konfabulator Widget">
<name>main_window</name>
<width>500</width>
<height>500</height>
</window>
<image src="Images/[Link]" name="sun1">
<hOffset>250</hOffset>
<vOffset>250</vOffset>
<alignment>center</alignment>
</image>
<text data="Click Here" size="36" style="bold">
<name>text1</name>
<hOffset>250</hOffset>
<vOffset>100</vOffset>
<alignment>center</alignment>
<onMouseUp>
[Link] = ([Link] / 100) * 90;
</onMouseUp>
</text>
</widget>
{"web-app": {
"servlet": [
{
"servlet-name": "cofaxCDS",
"servlet-class": "[Link]",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "ksm@[Link]",
"configGlossary:poweredBy": "Cofax",
"configGlossary:poweredByIcon": "/images/[Link]",
"configGlossary:staticPath": "/content/static",
"templateProcessorClass": "[Link]",
"templateLoaderClass": "[Link]",
"templatePath": "templates",
"templateOverridePath": "",
"defaultListTemplate": "[Link]",
"defaultFileTemplate": "[Link]",
"useJSP": false,
"jspListTemplate": "[Link]",
"jspFileTemplate": "[Link]",
"cachePackageTagsTrack": 200,
"cachePackageTagsStore": 200,
"cachePackageTagsRefresh": 60,
"cacheTemplatesTrack": 100,
"cacheTemplatesStore": 50,
"cacheTemplatesRefresh": 15,
"cachePagesTrack": 200,
"cachePagesStore": 100,
"cachePagesRefresh": 10,
"cachePagesDirtyRead": 10,
"searchEngineListTemplate": "[Link]",
"searchEngineFileTemplate": "[Link]",
"searchEngineRobotsDb": "WEB-INF/[Link]",
"useDataStore": true,
"dataStoreClass": "[Link]",
"redirectionClass": "[Link]",
"dataStoreName": "cofax",
"dataStoreDriver": "[Link]",
"dataStoreUrl":
"jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
"dataStoreUser": "sa",
"dataStorePassword": "dataStoreTestQuery",
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
"dataStoreLogFile": "/usr/local/tomcat/logs/[Link]",
"dataStoreInitConns": 10,
"dataStoreMaxConns": 100,
"dataStoreConnUsageLimit": 100,
"dataStoreLogLevel": "debug",
"maxUrlLength": 500}},
{
"servlet-name": "cofaxEmail",
"servlet-class": "[Link]",
"init-param": {
"mailHost": "mail1",
"mailHostOverride": "mail2"}},
{
"servlet-name": "cofaxAdmin",
"servlet-class": "[Link]"},
{
"servlet-name": "fileServlet",
"servlet-class": "[Link]"},
{
"servlet-name": "cofaxTools",
"servlet-class": "[Link]",
"init-param": {
"templatePath": "toolstemplates/",
"log": 1,
"logLocation": "/usr/local/tomcat/logs/[Link]",
"logMaxSize": "",
"dataLog": 1,
"dataLogLocation": "/usr/local/tomcat/logs/[Link]",
"dataLogMaxSize": "",
"removePageCache": "/content/admin/remove?cache=pages&id=",
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
"lookInContext": 1,
"adminGroupID": 4,
"betaServer": true}}],
"servlet-mapping": {
"cofaxCDS": "/",
"cofaxEmail": "/cofaxutil/aemail/*",
"cofaxAdmin": "/admin/*",
"fileServlet": "/static/*",
"cofaxTools": "/tools/*"},
"taglib": {
"taglib-uri": "[Link]",
"taglib-location": "/WEB-INF/tlds/[Link]"}}}
The same file expressed as XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"[Link]
<web-app>
<servlet>
<servlet-name>
cofaxCDS
</servlet-name>
<servlet-class>
[Link]
</servlet-class>
<init-param>
<param-name>configGlossary:installationAt</param-name>
<param-value>Philadelphia, PA</param-value>
</init-param>
<init-param>
<param-name>configGlossary:adminEmail</param-name>
<param-value>ksm@[Link]</param-value>
</init-param>
<init-param>
<param-name>configGlossary:poweredBy</param-name>
<param-value>Cofax</param-value>
</init-param>
<init-param>
<param-name>configGlossary:poweredByIcon</param-name>
<param-value>/images/[Link]</param-value>
</init-param>
<init-param>
<param-name>configGlossary:staticPath</param-name>
<param-value>/content/static</param-value>
</init-param>
<init-param>
<param-name>templateProcessorClass</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>templateLoaderClass</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>templatePath</param-name>
<param-value>templates</param-value>
</init-param>
<init-param>
<param-name>templateOverridePath</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>defaultListTemplate</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>defaultFileTemplate</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>useJSP</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>jspListTemplate</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>jspFileTemplate</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>cachePackageTagsTrack</param-name>
<param-value>200</param-value>
</init-param>
<init-param>
<param-name>cachePackageTagsStore</param-name>
<param-value>200</param-value>
</init-param>
<init-param>
<param-name>cachePackageTagsRefresh</param-name>
<param-value>60</param-value>
</init-param>
<init-param>
<param-name>cacheTemplatesTrack</param-name>
<param-value>100</param-value>
</init-param>
<init-param>
<param-name>cacheTemplatesStore</param-name>
<param-value>50</param-value>
</init-param>
<init-param>
<param-name>cacheTemplatesRefresh</param-name>
<param-value>15</param-value>
</init-param>
<init-param>
<param-name>cachePagesTrack</param-name>
<param-value>200</param-value>
</init-param>
<init-param>
<param-name>cachePagesStore</param-name>
<param-value>100</param-value>
</init-param>
<init-param>
<param-name>cachePagesRefresh</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param-name>cachePagesDirtyRead</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param-name>searchEngineListTemplate</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>searchEngineFileTemplate</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>searchEngineRobotsDb</param-name>
<param-value>WEB-INF/[Link]</param-value>
</init-param>
<init-param>
<param-name>useDataStore</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>dataStoreClass</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>redirectionClass</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>dataStoreName</param-name>
<param-value>cofax</param-value>
</init-param>
<init-param>
<param-name>dataStoreDriver</param-name>
<param-value>[Link]</param-value>
</init-param>
<init-param>
<param-name>dataStoreUrl</param-name>
<paramvalue>jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon</paramvalue>
</init-param>
<init-param>
<param-name>dataStoreUser</param-name>
<param-value>sa</param-value>
</init-param>
<init-param>
<param-name>dataStorePassword</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>dataStoreTestQuery</param-name>
<param-value>SET NOCOUNT ON;select test='test';</param-value>
</init-param>
<init-param>
<param-name>dataStoreLogFile</param-name>
<param-value>/usr/local/tomcat/logs/[Link]</param-value>
</init-param>
<init-param>
<param-name>dataStoreInitConns</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param-name>dataStoreMaxConns</param-name>
<param-value>100</param-value>
</init-param>
<init-param>
<param-name>dataStoreConnUsageLimit</param-name>
<param-value>100</param-value>
</init-param>
<init-param>
<param-name>dataStoreLogLevel</param-name>
<param-value>debug</param-value>
</init-param>
<init-param>
<param-name>maxUrlLength</param-name>
<param-value>500</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>
cofaxEmail
</servlet-name>
<servlet-class>
[Link]
</servlet-class>
<init-param>
<param-name>mailHost</param-name>
<param-value>mail1</param-value>
</init-param>
<init-param>
<param-name>mailHostOverride</param-name>
<param-value>mail2</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>
cofaxAdmin
</servlet-name>
<servlet-class>
[Link]
</servlet-class>
</servlet>
<servlet>
<servlet-name>
fileServlet
</servlet-name>
<servlet-class>
[Link]
</servlet-class>
</servlet>
<servlet>
<servlet-name>
cofaxTools
</servlet-name>
<servlet-class>
[Link]
</servlet-class>
<init-param>
<param-name>templatePath</param-name>
<param-value>toolstemplates/</param-value>
</init-param>
<init-param>
<param-name>log</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>logLocation</param-name>
<param-value>/usr/local/tomcat/logs/[Link]</param-value>
</init-param>
<init-param>
<param-name>logMaxSize</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>dataLog</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>dataLogLocation</param-name>
<param-value>/usr/local/tomcat/logs/[Link]</param-value>
</init-param>
<init-param>
<param-name>dataLogMaxSize</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>removePageCache</param-name>
<param-value>/content/admin/remove?cache=pages&id=</param-value>
</init-param>
<init-param>
<param-name>removeTemplateCache</param-name>
<param-value>/content/admin/remove?cache=templates&id=</paramvalue>
</init-param>
<init-param>
<param-name>fileTransferFolder</param-name>
<param-value>/usr/local/tomcat/webapps/content/fileTransferFolder</paramvalue>
</init-param>
<init-param>
<param-name>lookInContext</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>adminGroupID</param-name>
<param-value>4</param-value>
</init-param>
<init-param>
<param-name>betaServer</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>
cofaxCDS
</servlet-name>
<url-pattern>
/
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
cofaxEmail
</servlet-name>
<url-pattern>
/cofaxutil/aemail/*
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
cofaxAdmin
</servlet-name>
<url-pattern>
/admin/*
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
fileServlet
</servlet-name>
<url-pattern>
/static/*
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
cofaxTools
</servlet-name>
<url-pattern>
/tools/*
</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>[Link]</taglib-uri>
<taglib-location>/WEB-INF/tlds/[Link]</taglib-location>
</taglib>
</web-app>
The action and label values only need to be provided if they are not the same as the
id.
{"menu": {
"header": "SVG Viewer",
"items": [
{"id": "Open"},
{"id": "OpenNew", "label": "Open New"},
null,
{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"},
null,
{"id": "Quality"},
{"id": "Pause"},
{"id": "Mute"},
null,
{"id": "Find", "label": "Find..."},
{"id": "FindAgain", "label": "Find Again"},
{"id": "Copy"},
{"id": "CopyAgain", "label": "Copy Again"},
{"id": "CopySVG", "label": "Copy SVG"},
{"id": "ViewSVG", "label": "View SVG"},
{"id": "ViewSource", "label": "View Source"},
{"id": "SaveAs", "label": "Save As"},
null,
{"id": "Help"},
{"id": "About", "label": "About Adobe CVG Viewer..."}
]
}}
The same message expressed as XML:
<menu>
<header>Adobe SVG Viewer</header>
<item action="Open" id="Open">Open</item>
<item action="OpenNew" id="OpenNew">Open New</item>
<separator/>
<item action="ZoomIn" id="ZoomIn">Zoom In</item>
<item action="ZoomOut" id="ZoomOut">Zoom Out</item>
<item action="OriginalView" id="OriginalView">Original View</item>
<separator/>
<item action="Quality" id="Quality">Quality</item>
<item action="Pause" id="Pause">Pause</item>
<item action="Mute" id="Mute">Mute</item>
<separator/>
<item action="Find" id="Find">Find...</item>
<item action="FindAgain" id="FindAgain">Find Again</item>
<item action="Copy" id="Copy">Copy</item>
<item action="CopyAgain" id="CopyAgain">Copy Again</item>
<item action="CopySVG" id="CopySVG">Copy SVG</item>
<item action="ViewSVG" id="ViewSVG">View SVG</item>
<item action="ViewSource" id="ViewSource">View Source</item>
<item action="SaveAs" id="SaveAs">Save As</item>
<separator/>
<item action="Help" id="Help">Help</item>
<item action="About" id="About">About Adobe CVG Viewer...</item>
</menu>
using System;
using [Link];
using [Link];
using [Link];
public class main
{
public static void Main(string[] args)
{
try
{
//Create a TCP connection to a listening TCP process.
//Use "localhost" to specify the current computer or
//replace "localhost" with the IP address of the
//listening process.
TcpClient TCP = new TcpClient("localhost",11000);
//Create a network stream from the TCP connection.
NetworkStream NetStream = [Link]();
//Create a new instance of the RijndaelManaged class
// and encrypt the stream.
RijndaelManaged RMCrypto = new RijndaelManaged();
byte[] Key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16};
byte[] IV = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16};
//Create a CryptoStream, pass it the NetworkStream, and encrypt
//it with the Rijndael class.
CryptoStream CryptStream = new CryptoStream(NetStream,
[Link](Key, IV),
[Link]);
//Create a StreamWriter for easy writing to the
//network stream.
StreamWriter SWriter = new StreamWriter(CryptStream);
//Write to the stream.
[Link]("Hello World!");
//Inform the user that the message was written
//to the stream.
[Link]("The message was sent.");
//Close all the connections.
[Link]();
[Link]();
[Link]();
[Link]();
}
catch
{
//Inform the user that an exception was raised.
[Link]("The connection failed.");
}
}
}
class ExceptionTest
{
static double SafeDivision(double x, double y)
{
if (y == 0)
throw new [Link]();
return x / y;
}
static void Main()
{
// Input for test purposes. Change the values to see
// exception handling behavior.
double a = 98, b = 0;
double result = 0;
try
{
result = SafeDivision(a, b);
[Link]("{0} divided by {1} = {2}", a, b, result);
}
catch (DivideByZeroException e)
{
[Link]("Attempted divide by zero.");
}
}
}
int caseSwitch = 1;
switch (caseSwitch)
{
case 1:
[Link]("Case 1");
break;
case 2:
[Link]("Case 2");
break;
default:
[Link]("Default case");
break;
}
public void Test()
{
for (int i = 1; i < 101; i++)
{
if (i % 3 == 0 && i % 5 == 0)
{
[Link]("FizzBuzz");
}
else if (i % 3 == 0)
{
[Link]("Fizz");
}
else if (i % 5 == 0)
{
[Link]("Buzz");
}
else
{
[Link](i);
}
}
}
What do you think? Do we need to make the code better?
Example 2:
Hide Copy Code
public void Check()
{
for (int i = 1; i <= 100; i++)
{
string output = "";
if (i % 3 == 0) { output = "Fizz"; }
if (i % 5 == 0) { output = output + "Buzz"; }
if (output == "") { output = [Link](); }
[Link](output);
}
}
What do you think now ? Do we need to make the code even better?
Ok, let me help to make it better. Naming thing is one of the hardest job we have as
a software developer. Because we spend a lot of time naming things, there are so
many things to name properties, methods, classes, files, projects etc. We should
spend some energies for naming things because names can be meanings. Adding
meaning to code is readability all about.
Hide Copy Code
public void DoFizzBuzz()
{
for (int number = 1; number <= 100; number++)
{
var output = GetFizzBuzzOutput(number);
[Link](output);
}
}
private static string GetFizzBuzzOutput(int number)
{
string output = [Link];
if (number%3 == 0)
{
output = "Fizz";
}
if (number%5 == 0)
{
output += "Buzz";
}
if([Link](output))
{
output = [Link]();
}
return output;
}
ublic class Product
{
public void GetActiveProducts()
{
//...
}
public void CalculateProductAdditinalCost()
{
//...
}
}
Do use camelCasing for method arguments and local variables.
Hide Copy Code
public class ProductCategory
{
public void Save(ProductCategory productCategory)
{
// ...
}
}
Do not use Abbreviations.
Hide Copy Code
// Correct
ProductCategory productCategory;
// Avoid
ProductCategory prodCat;
Do not use Underscores in identifiers.
Hide Copy Code
// Correct
ProductCategory productCategory;
// Avoid
ProductCategory product_Category;
Do prefix interfaces with the letter I.
Hide Copy Code
public interface IAddress
{
}
Do declare all member variables at the top of a class, with static variables at the
very top.
Hide Copy Code
public class Product
{
public static string BrandName;
public string Name{get; set;}
public DateTime DateAvailable {get; set;}
public Product()
{
// ...
}
}
Do use singular names for enums. Exception: bit field enums.
Hide Copy Code
public enum Direction
{
North,
East,
South,
West
}
Do not suffix enum names with Enum.
Hide Copy Code
//Avoid
public enum DirectionEnum
{
North,
East,
South,
West
}
//avoid
public void Checkout(string shippingName, string shippingCity,
string shippingSate, string shippingZip, string billingName,
string billingCity, string billingSate, string billingZip)
{
}
Hide Copy Code
//DO
public void Checkout(ShippingAddress shippingAddress,BillingAddress
billingAddress)
{
}
We should introduce class instead of all parameters.
Avoid Complex Expressions
Hide Copy Code
if([Link]>500 && ![Link] &&
![Link] && [Link])
{
// do something
}
Hide Copy Code
//avoid
if([Link]>15)
{
return false;
}
else if([Link])
{
return false;
}
else if(![Link])
{
return false;
}
else if()
{
//.....
}
return true;
Hide Copy Code
//DO
var isValid = true;
if([Link]>15)
{
isValid= false;
}
else if([Link])
{
isValid= false;
}
else if(![Link])
{
isValid= false;
}
return isValid;
You can imagine 4 exit points scattered around 20- 30 lines of code. That makes you
more harder to understand and see what is happening inside the method and what
will execute and when will execute.
I got too many responses, some agreeing but mostly disagreeing that it was a good
"standard" to enforce. To find out the potentiality I did some unit testing and found
that for complex method that have multiple exit points usually have a set of tests
for each of those paths.
Hide Copy Code
if( BADFunction() == true)
{
// expression
if( anotherFunction() == true )
{
// expression
return true;
}
else
{
//error
}
}
else
{
//error
}
return false;
Hide Copy Code
if( !GoodFunction())
{
// error.
return false
}
// expression
if( !GoodFunction2())
{
//error.
return false;
}
// more expression
return true;
namespace [Link]
{
public class Customer
{
public string CustomerName { get; set; }
public string Address { get; set; }
}
public class TestController : Controller
{
public Customer GetCustomer()
{
Customer c = new Customer();
[Link] = "Customer 1";
[Link] = "Address1";
return c;
}
}
}
public override string ToString()
{
return [Link]+"|"+[Link];
}
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>MyView</title>
</head>
<body>
public ActionResult GetView()
{
if(Some_Condition_Is_Matching)
{
return View("MyView");
}
else
{
return View("YourView");
}
}
public ActionResult GetView()
{
if(Some_Condition_Is_Matching)
{
return View("MyView");
}
else
{
return Content("Hi Welcome");
}
}
public class Customer
{
private string _Code;
private int _Id;
private double _Amount;
public string CustomerCode
{
set
{
_Code = value;
}
get
{
return _Code;
}
}
public int Id
{
get
{
return _Id;
}
set
{
_Id= value;
}
}
public double Amount
{
set
{
_Amount = value;
}
get
{
return _Amount;
}
}
}
public class CustomerController : Controller
{
…..
….
public ViewResult DisplayCustomer()
{
Customer objCustomer = new Customer();
[Link] = 12;
[Link] = "1001";
[Link] = 90.34;
return View("DisplayCustomer",objCustomer);
}
}
public class CustomerController : Controller
{
…..
….
public ViewResult DisplayCustomer()
{
Customer objCustomer = new Customer();
[Link] = 12;
[Link] = "1001";
[Link] = 90.34;
return View("DisplayCustomer",objCustomer);
}
}
<form action="DisplayCustomer" method="post">
Enter customer id :- <input type="text" name="Id" /> <br />
Enter customer code :- <input type="text" name="CustomerCode" /><br />
Enter customer Amount :-<input type="text" name="Amount" /><br />
<input type="submit" value="Submit customer data" />
</form>