实战 .NET - Web App - Web Server Control(0分)

Y

yysun

Unregistered / Unconfirmed
GUEST, unregistred user!
如果您已经成功运行第一和第二个 web app,下面可以试验一下 Web Server Control
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1137891
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1139240
步骤:
1、dfw 目录下建文件:hi3.aspx 内容为:
<%@ Page Language="C#" EnableSessionState="False" debug="false" strict="true"
Inherits="dfw.HClass2" %>
<form runat="server">
<asp:Label id="label1" runat="server"/>
</form>
2、src 目录下建文件:hi3.cs 内容为:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dfw {
public class HClass2 : System.Web.UI.Page {
protected Label label1;
protected void Page_Load(object sender, System.EventArgs e) {
try{
HiClass clsHi = new HiClass();
label1.Text = clsHi.Hi;
}
catch(Exception ex) {
Response.Write("<pre>"+ex.ToString()+"</per>");
}
}
}
}
3、用 mk.bat 编译
4、运行 hi3.aspx http://localhost/dfw/hi3.aspx
Web Server Controls 可是 ASP.NET 的重头戏。
我的体会是虽然 .NET Framework (类似 JVM) 免费,但是,.NET 非常推崇 web control。
而要用好 web control,必然需要 Visual Studio .NET,这就是 MS 赚钱之道。
反观 Java,JVM 免费,7-8 年下来 Sun 都没有好好搞个 IDE 出来,真是不如 MS 会赚钱。
这里我们只演示了最简单的 asp:Label,其他 Control,大家可以看:
http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconaspsyntaxforwebcontrols.asp
 
不明白Label1为什么在Aspx和CS文件中要重复声明。
 
不知道这是不是传说中的深入浅出。
 
》不明白Label1为什么在Aspx和CS文件中要重复声明。
有道理啊,这个爆麻烦,在IDE里就没有这个问题。一个不恰当的比喻,就像DELPHI里的DFM和PAS
DFM里
OBJECT BUTTON1 .....
PAS 里也有
BUTTON1:TBUTTON
这就是IDE两路代码开发(??/)的优势。DELPHI当年就靠这个吃饭的。
 
》不明白Label1为什么在Aspx和CS文件中要重复声明。
aspx里可以嵌html代码,用<asp:label.../>你就可以选择放在网页的哪个地方.
在cs里你可以用lavel.Text +=....重复输出。。
framworkSDK文档里有个quickstart有很多入门的例子,很有帮助
 
第三课[:D]
 
是不是和taglib差不多
 

Similar threads

Y
回复
7
查看
428
yxjdelphi
Y
Y
回复
28
查看
668
delphi_krush
D
Y
回复
226
查看
3K
nong
N
Y
回复
18
查看
285
yangying_2000
Y
顶部