日期:2014-05-18  浏览次数:20500 次

那位高手能给出一个MVC模式的程序的标准写法?
我也用MVC模式写了一段时间,但是发现有几种写法,不知道到底哪种是最标准的,性能方面也没有比较过,请教高手们用MVC代码的写法?给出代码事例,谢谢!

------解决方案--------------------
沙发,帮忙顶
------解决方案--------------------
<%@ Page language= "c# " Codebehind= "Default.aspx.cs " AutoEventWireup= "false " Inherits= "CN.Teddy.AjaxHelper.WebForm1 " %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN " >
<HTML>
<HEAD>
<title> WebForm1 </title>
<meta name= "GENERATOR " Content= "Microsoft Visual Studio .NET 7.1 ">
<meta name= "CODE_LANGUAGE " Content= "C# ">
<meta name= "vs_defaultClientScript " content= "JavaScript ">
<meta name= "vs_targetSchema " content= "http://schemas.microsoft.com/intellisense/ie5 ">
<script type= "text/javascript " language= "javascript " src= "js/AjaxHelper.js "> </script>
</HEAD>
<body>
<form id= "Form1 " method= "post " runat= "server ">
<div id= "view2 "> loading </div>
<script type= "text/javascript ">
Updater( 'AjaxTemplate/GetPageSrc ', 'view2 ', 'url=http://www.cnblogs.com ');
</script>

</form>
</body>
</HTML>
---------------------
var AjaxHelperUrl = new String( "Ajax.aspx ");


var Updater = function(ajaxTemplate, output, params, onComplete)

{

if (typeof output == 'string ')

{

output = $(output);

}



new Ajax.Request( 'Ajax.aspx ', { onComplete: function(transport) { if (output != null) { output.innerHTML = FormatContent(transport.responseText); } if (onComplete != null) { onComplete(FormatContent(transport.responseText)) } }, parameters: params + '&AjaxTemplate= ' + ajaxTemplate });

}


var SerializeForm = function(form)

{

return Form.serialize(form);

}


var FormatContent = function(str)

{

var content = new String(str);

var prefix = new String( " <!--AjaxContent--> ");

content = content.substring(content.indexOf(prefix, 0) + prefix.length, content.length - 9);

return content;

}
--------------------------------------------
private void Page_Load(object sender, System.EventArgs e)
{
lbUrl.Text = Request.Form[ "url "];

System.Net.WebClient client = new System.Net.WebClient();
client.Headers.Add( "User-Agent ", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322) ");
try
{
txtPageSource.Text = new System.IO.StreamReader(client.OpenRead(lbUrl.Text), System.Text.Encoding.UTF8).ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
}
------解决方案--------------------
嗯 等看