01. Getting Started with Visual Web Developer 2005 Express Edition

本文探讨了Default.aspx与Default2.aspx之间的主要差异,前者使用独立的代码隐藏文件Default.aspx.cs,后者将代码置于页面内。尽管实现方式不同,但最终生成的HTML相同。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.gif

Default.aspx 和Default2.aspx的区别
Default.aspx 是有 Default.aspx.cs文件的,而Default2.aspx没有,这点在创建是可以选择.这是2003版本没有的.


Defult.aspx 代码:
ExpandedBlockStart.gifContractedBlock.gif<%dot.gif@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
None.gif
None.gif
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
None.gif
None.gif
<html xmlns="http://www.w3.org/1999/xhtml" >
None.gif
<head runat="server">
None.gif    
<title>无标题页</title>
None.gif
</head>
None.gif
<body>
None.gif    
<form id="form1" runat="server">
None.gif        
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><asp:Button ID="Button1"
None.gif            runat
="server" Text="Button" OnClick="Button1_Click" />
None.gif    
<div>
None.gif    
None.gif    
</div>
None.gif    
</form>
None.gif
</body>
None.gif
</html>
None.gif


Defult2.aspx 代码:

ExpandedBlockStart.gifContractedBlock.gif<%dot.gif@ Page Language="C#" %>
None.gif
None.gif
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
None.gif
ExpandedBlockStart.gifContractedBlock.gif
<script runat="server">dot.gif
InBlock.gif
InBlock.gif    protected 
void Button1_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
this.Label1.Text = "HellowWorld!";
ExpandedBlockEnd.gif    }

None.gif
</script>
None.gif
None.gif
<html xmlns="http://www.w3.org/1999/xhtml" >
None.gif
<head runat="server">
None.gif    
<title>无标题页</title>
None.gif
</head>
None.gif
<body>
None.gif    
<form id="form1" runat="server">
None.gif    
<div>
None.gif        
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
None.gif        
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
None.gif    
None.gif    
</div>
None.gif    
</form>
None.gif
</body>
None.gif
</html>
None.gif


最后生成的html是完全一样的.
None.gif
None.gif
None.gif
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
None.gif
None.gif
None.gif
None.gif
<html xmlns="http://www.w3.org/1999/xhtml" >
None.gif
<head><title>
None.gif    无标题页
None.gif
</title></head>
None.gif
<body>
None.gif    
<form name="form1" method="post" action="Default2.aspx" id="form1">
None.gif
<div>
None.gif
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE4OTg4OTc0MjVkZGoMrqzL34hFGRqKFN+6lxVLjJFs" />
None.gif
</div>
None.gif
None.gif    
<div>
None.gif        
<span id="Label1">Label</span>
None.gif        
<input type="submit" name="Button1" value="Button" id="Button1" />
None.gif    
None.gif    
</div>
None.gif    
None.gif
<div>
None.gif
None.gif    
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKC0PCACwKM54rGBoNtyfDVjmYjg4/kzd5esA78sqTN" />
None.gif
</div></form>
None.gif
</body>
None.gif
</html>
None.gif

转载于:https://www.cnblogs.com/csuwhl/archive/2006/08/27/487628.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值