高分求教一个简单问题(在线等待)

xuchunqiang 2003-02-17 09:07:20
文件holidaypage.aspx如下:

<html>
<head>
<title>Holiday page</title>
</head>
<body>
<form action="holidayresponse.aspx" method="post">

修改时加入<form runat="server">

<h1>Feiertag Holidays</h1>
Please enter your details here.
<br /><br />
Name:<asp:textbox id="FullName" runat="server" />
<br /><br />
Address:<asp:textbox id="Address" rows="5" textmode="multiline" runat="server" />
<br /><br />
Sex -
<asp:radiobuttonlist id="sex" runat="server">
<asp:listitem value="Male" />
<asp:listitem value="Female" />
</asp:radiobuttonlist>
Please select the destination you would like details on:
<asp:dropdownlist id="Destination" runat="server">
<asp:listitem value="Madrid" />
<asp:listitem value="Barcelona"/>
<asp:listitem value="Lisbon"/>
<asp:listitem value="Oslo"/>
<asp:listitem value="Prague"/>
</asp:dropdownlist>
<br /><br />
<input type="Submit">
<input type="Reset">

修改时加入</form>

</form>
</body>
</html>

文件holidayresponse.aspx如下:
<script runat="server" language="vb">
Sub Page_Load()
Response.Write ("<b>Name:</b> " + Request.Form("FullName") + "<br />")
Response.Write ("<b>Address:</b> " + Request.Form("Address") + "<br />")
Response.Write ("<b>Sex:</b> " + Request.Form("Sex") + "<br />")
Response.Write ("<b>Destination:</b> " + Request.Form("Destination") + "<br />")
End Sub
</script>
<html>
<head>
<title>Holiday page</title>
</head>
<body>
<br /><br />
These details have been entered into our database, you should receive a confirmation email from us shortly.
<br /><br />
</body>
</html>

但运行holidaypage后出现的第一个问题是错误提示:
类型“TextBox”的控件“FullName”必须放在具有 runat=server 的窗体标记内
因为是菜鸟,用上面的方法修改后,可以运行,但单击“提交”按钮后,在holidayresponse又出现错误提示:
此页的视图状态无效,并且可能已损坏。
正确方法应是什么,请赐教!
...全文
23 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuchunqiang 2003-02-18
  • 打赏
  • 举报
回复
菜鸟请教下面代码错在哪?
<script runat="server" language="vb">
Sub Button1_Click(sender as object, e as EventArgs)
Dim url as string
url="anotherwebform.aspx?name=" + TextBox1.Text
Response.Redirect(url);
End Sub
</script>

<html>
<head>
<title>Test</title>
</head>
<body>
<form runat="server">
This is a test page.
Name:<asp:textbox id="textbox1" runat="server" width=100/>
<input type="button" id="button1" value="Submit">
</form>
</body>
</html>
oh_love 2003-02-18
  • 打赏
  • 举报
回复
一样 Response.Redirect("url")
xuchunqiang 2003-02-18
  • 打赏
  • 举报
回复
http://www.dotnetbips.com/displayarticle.aspx?id=79上是用C#写的吧,有一句这样
Response.Redirect(url);在VB中该如何表示呢?
saucer 2003-02-17
  • 打赏
  • 举报
回复
see how it is done:
Passing Values between ASP.NET Web Forms
http://www.dotnetbips.com/displayarticle.aspx?id=79

or try
holidaypage.aspx:
<script runat="server" language="vb">
Sub Page_Load()
if IsPostBack then
Server.Transfer("holidayresponse.aspx",true)
end if
End Sub
</script>

<html>
<head>
<title>Holiday page</title>
</head>
<body>
<form runat="server">

<h1>Feiertag Holidays</h1>
Please enter your details here.
<br /><br />
Name:<asp:textbox id="FullName" runat="server" />
<br /><br />
Address:<asp:textbox id="Address" rows="5" textmode="multiline" runat="server" />
<br /><br />
Sex -
<asp:radiobuttonlist id="sex" runat="server">
<asp:listitem value="Male" />
<asp:listitem value="Female" />
</asp:radiobuttonlist>
Please select the destination you would like details on:
<asp:dropdownlist id="Destination" runat="server">
<asp:listitem value="Madrid" />
<asp:listitem value="Barcelona"/>
<asp:listitem value="Lisbon"/>
<asp:listitem value="Oslo"/>
<asp:listitem value="Prague"/>
</asp:dropdownlist>
<br /><br />
<input type="Submit">
<input type="Reset">

</form>
</body>
</html>

holidayresponse.aspx:
<%@ Page EnableViewStateMac="false" %>
<script runat="server" language="vb">
Sub Page_Load()
Response.Write ("<b>Name:</b> " + Request.Form("FullName") + "<br />")
Response.Write ("<b>Address:</b> " + Request.Form("Address") + "<br />")
Response.Write ("<b>Sex:</b> " + Request.Form("Sex") + "<br />")
Response.Write ("<b>Destination:</b> " + Request.Form("Destination") + "<br />")
End Sub
</script>
<html>
<head>
<title>Holiday page</title>
</head>
<body>
<br /><br />
These details have been entered into our database, you should receive a confirmation email from us shortly.
<br /><br />
</body>
</html>
xuchunqiang 2003-02-17
  • 打赏
  • 举报
回复
但我是想让反馈的结果在holidayresponse中显示,如上面问题的第二段代码。
saucer 2003-02-17
  • 打赏
  • 举报
回复
try


holidaypage.aspx:

<script runat="server" language="vb">
Sub Page_Load()
if IsPostBack then
Response.Write ("<b>Name:</b> " + FullName.Text + "<br />")
Response.Write ("<b>Address:</b> " + Address.Text + "<br />")
Response.Write ("<b>Sex:</b> " + Sex.SelectedItem.Value + "<br />")
Response.Write ("<b>Destination:</b> " + Destination.SelectedItem.Value + "<br />")
end if
End Sub
</script>

<html>
<head>
<title>Holiday page</title>
</head>
<body>
<form runat="server">

<h1>Feiertag Holidays</h1>
Please enter your details here.
<br /><br />
Name:<asp:textbox id="FullName" runat="server" />
<br /><br />
Address:<asp:textbox id="Address" rows="5" textmode="multiline" runat="server" />
<br /><br />
Sex -
<asp:radiobuttonlist id="sex" runat="server">
<asp:listitem value="Male" />
<asp:listitem value="Female" />
</asp:radiobuttonlist>
Please select the destination you would like details on:
<asp:dropdownlist id="Destination" runat="server">
<asp:listitem value="Madrid" />
<asp:listitem value="Barcelona"/>
<asp:listitem value="Lisbon"/>
<asp:listitem value="Oslo"/>
<asp:listitem value="Prague"/>
</asp:dropdownlist>
<br /><br />
<input type="Submit">
<input type="Reset">

</form>
</body>
</html>

62,046

社区成员

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

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

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

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