Index. aspx:
<Script SRC= ".../Scripts/jquery-1.3.2.js" Type= "Text/JavaScript"> </Script>
<SCRIPT src =".../Scripts/microsoftajax. js"Type ="Text/JavaScript"> </SCRIPT>
<SCRIPT src =".../Scripts/microsoftmvcajax. js"Type ="Text/JavaScript"></Script>
<H3>Ajax. beginform</H3>
<H4>Comments</H4>
<Ul ID= "Comments">
</Ul>
<% Using(Ajax. beginform ("Addcomment",NewAjaxoptions
{
Httpmethod ="Post",
Updatetargetid ="Comments",
Insertionmode = insertionmode. insertafter
})){%>
<%= Html. textarea ("Comment",New{Rows = 5, cols = 50 })%>
<Button Type= "Submit">Add Comment</Button>
<%}%>
<H3>Ajax. Link</H3>
<%= Ajax. actionlink ("Show the Privacy Policy","Privacypolicy",
NewAjaxoptions {insertionmode = insertionmode. Replace, updatetargetid ="Privacy"})%>
<Div ID= "Privacy"> </Div>
Ajaxhelperscontroller. CS:
Public ClassAjaxhelperscontroller: Controller
{
PrivateIlist <String> _ Comments =NewList <String> ();
PublicActionresult index ()
{
ReturnView (_ Comments );
}
[Httppost]
PublicActionresult addcomment (StringComment)
{
_ Comments. Add ("<Li>"+ Comment +"</LI>");
ReturnContent (String. Join ("\ N", _ Comments. toarray ()));
}
PublicActionresult privacypolicy ()
{
Const StringPrivacytext =@"
<H2> our commitment to privacy </H2>
Your privacy is important to us. To better protect your privacy we provide this notice explaining our online
Information practices and the choices you can make about the way your information is collected and used.
To make this notice easy to find, we make it available on our homepage and at every point where personally
Identifiable information may be requested .";
ReturnContent (privacytext,"Text/html");
}
}