部分范例源码
Defaultaspx
<%@Pagelanguage=
c#
Codebehind=
Default
aspx
cs
AutoEventWireup=
false
Inherits=
CN
Teddy
AjaxHelper
WebForm
%>
<!DOCTYPEHTMLPUBLIC//WC//DTDHTMLTransitional//EN>
<HTML>
<HEAD>
<title>WebForm</title>
<metaname=GENERATORContent=MicrosoftVisualStudioNET>
<metaname=CODE_LANGUAGEContent=C#>
<metaname=vs_defaultClientScriptcontent=JavaScript>
<metaname=vs_targetSchemacontent=http://schemasmicrosoftcom/intellisense/ie>
<scripttype=text/javascriptlanguage=javascriptsrc=js/AjaxHelperjs></script>
</HEAD>
<body>
<formid=Formmethod=postrunat=server>
<divid=view>loading</div>
<scripttype=text/javascript>
Updater(AjaxTemplate/GetPageSrcviewurl=http://wwwcnblogscom);
</script>
</form>
</body>
</HTML>
AjaxHelperjs摘要
varAjaxHelperUrl=newString(Ajaxaspx);
varUpdater=function(ajaxTemplateoutputparamsonComplete)
{
if(typeofoutput==string)
{
output=$(output);
}
newAjaxRequest(Ajaxaspx{onComplete:function(transport){if(output!=null){outputinnerHTML=FormatContent(transportresponseText);}if(onComplete!=null){onComplete(FormatContent(transportresponseText))}}parameters:params+&AjaxTemplate=+ajaxTemplate});
}
varSerializeForm=function(form)
{
returnFormserialize(form);
}
varFormatContent=function(str)
{
varcontent=newString(str);
varprefix=newString(<!AjaxContent>);
content=contentsubstring(contentindexOf(prefix)+prefixlengthcontentlength);
returncontent;
}
UserControl GetPageSrcascxcs摘要
privatevoidPage_Load(objectsenderSystemEventArgse)
{
lbUrlText=RequestForm[url];
SystemNetWebClientclient=newSystemNetWebClient();
clientHeadersAdd(UserAgentMozilla/(compatible;MSIE;WindowsNT;NETCLR));
try
{
txtPageSourceText=newSystemIOStreamReader(clientOpenRead(lbUrlText)SystemTextEncodingUTF)ReadToEnd();
}
catch(Exceptionex)
{
throwex;
}
}
[] []