单个文件页面模型aspx.net程序:新手程序

时间:2014-12-04 18:28:58

标签: asp.net

感谢您提供非常准确的答案。我试过了。仍然没有任何反应 请注意,我将写入"响应"和"追踪"我什么也没看到 GoDaddy提供的日志:

<%@Page language="vb" Debug="true"%>
<script language="vb" runat="server">
Protected Sub Button1_Click(ByVal Sender as Object, _
ByVal e as System.EventArgs)
dim sum as integer
dim input as integer
response.write("RW")
trace.write("TW")

If not ViewState("nnn") is nothing then
sum = ViewState("nnn")
end if
input = txtInput.text
sum = sum + input

ViewState("sum") = sum
txtsum.text = sum

end sub
</script>
<html>
<body>
<form id="form" runat="server">
<p>Input:<asp:TextBox ID="txtinput" runat="server" maxlength="10" enabled="true"/></p>
<p>Sum:<asp:TextBox ID="txtsum" runat="server" maxlength="10" enabled="true"/></p>
<p><input type="submit" value="Add Em" onClick="Button1_Click" runat="server"/>
</form>
</body>
</html>

Intermittantly,我从服务器收到错误消息:

Validation of viewstate MAC failed.  If an application is hosted by a WEb Farm or cluster, ensure that
<machineKey> configuration specifies the same validationKey and validation algorithm.
AutoGenerate cannot be used in acluster.

S  ee http://go.microsoft.com/fwlink/?lLinkID=314055 for more information

我采访了godaddy的技术支持;因为他们不能重现问题,他们 无法帮助我。

P上。谢谢你,香蕉,你对我的推杆电话和传统邮件的关注 联系本网站上的信息,通常, 我是在StackOverflow等论坛的帖子中这样做的 和Usenet新闻。我从来没有得到这些旧通信的回应 方法,通缉或其他。

2 个答案:

答案 0 :(得分:1)

输入按钮必须是runat =&#34; server&#34;以及为了使其发挥作用。

答案 1 :(得分:0)

<%@Page language="vb" Debug="true"%>
<script language="vb" runat="server">
  Protected Sub x(ByVal Sender as Object, _
   ByVal e as System.EventArgs)
dim sum as integer
dim input as integer
response.write("RW")
trace.write("TW")

If not ViewState("sum") is nothing then
  sum = ViewState("sum")
end if
input = txtInput.text
sum = sum + input

ViewState("sum") = sum
txtsum.text = sum

end sub
</script>
<html>
<body>
<form id="form" runat="server">
<p>Input:<asp:TextBox ID="txtinput" runat="server" maxlength="10" enabled="true"/></p>
<p>Sum:<asp:TextBox ID="txtsum" runat="server" maxlength="10" enabled="true"/></p>
<p><asp:button  Text="Add Em!!"  onClick="x" runat="server"/>
</form>
</body>
</html>

我需要使用“asp:button”而不是“input type = submit”感谢大家。