从电子图书上拷贝的代码却编译通不过——真见鬼!

mituzhishi 2004-07-01 05:45:19
源代码:

<Html>
<ASP:Table Id="Table1" BorderWidth="1px" GridLines="Both"
Cellspacing="0"
Cellpadding="1"
Runat="Server" />
<Script Language="VB" Runat="Server">
Sub Page_Load(Sender As Object,e As Eventargs)
Dim I, J As Short
For I=0 To 4
Dim Row As New TableRow
For J=0 to 3
Dim Cell As New TableCell
Cell.Text=" Column=" & J
If J=3 Then
Dim btnA As New Button
btnA.Text ="Column=3"
Cell.Controls.Add(btnA)
End If
Row.Cells.Add(Cell)
Next
Table1.Rows.Add(Row)
Next
End Sub
</Script>
</Html>

代码来源:


《ASP.NET 程序设计基础篇》 原 作 者:林煌章


异常详细信息: System.Web.HttpException: 类型“Button”的控件“_ctl0”必须放在具有 runat=server 的窗体标记内。



我怀疑是我的配置版本太新了:版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zpisgod 2004-07-01
  • 打赏
  • 举报
回复
验证一句话:尽信书不如无书!


yeziforever 2004-07-01
  • 打赏
  • 举报
回复
aivii 2004-07-01
  • 打赏
  • 举报
回复
<Html>
<form runat=server>
<ASP:Table Id="Table1" BorderWidth="1px" GridLines="Both"
Cellspacing="0"
Cellpadding="1"
Runat="Server" />
</form>
<Script Language="VB" Runat="Server">
Sub Page_Load(Sender As Object,e As Eventargs)
Dim I, J As Short
For I=0 To 4
Dim Row As New TableRow
For J=0 to 3
Dim Cell As New TableCell
Cell.Text=" Column=" & J
If J=3 Then
Dim btnA As New Button
btnA.Text ="Column=3"
Cell.Controls.Add(btnA)
End If
Row.Cells.Add(Cell)
Next
Table1.Rows.Add(Row)
Next
End Sub
</Script>
</Html>
孟子E章 2004-07-01
  • 打赏
  • 举报
回复
<Html>
<form runat=server>
<ASP:Table Id="Table1" BorderWidth="1px" GridLines="Both"
Cellspacing="0"
Cellpadding="1"
Runat="Server" />
</form>
<Script Language="VB" Runat="Server">
Sub Page_Load(Sender As Object,e As Eventargs)
Dim I, J As Short
For I=0 To 4
Dim Row As New TableRow
For J=0 to 3
Dim Cell As New TableCell
Cell.Text=" Column=" & J
If J=3 Then
Dim btnA As New Button
btnA.Text ="Column=3"
Cell.Controls.Add(btnA)
End If
Row.Cells.Add(Cell)
Next
Table1.Rows.Add(Row)
Next
End Sub
</Script>
</Html>

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧