发post.aspx 代码看下,textbox是否有runat="server"属性,没有后台无法引用控件,获取值需要用Request对象
你看看textbox是你定义还是其他人的asp定义的,如果你定义的,可能与asp文件的定义不相符
希望对你有帮助,如有帮助,望采纳,谢谢
您的问题已经有小伙伴解答了,请点击【采纳】按钮,采纳帮您提供解决思路的答案,给回答的人一些鼓励哦~~
ps:开通问答VIP,享受5次/月 有问必答服务,了解详情↓↓↓
【电脑端】戳>>> https://vip.csdn.net/askvip?utm_source=1146287632
【APP 】 戳>>> https://mall.csdn.net/item/52471?utm_source=1146287632
上面这是post.aspx.cs代码
下面是post.aspx代码
不要截图,不要拍照,整个页面代码复制下来,代码顶部的 using 不要丢,页面顶部的 Page 声明不要丢
有可能是原来的页面的项目类型与你现在的项目类型不一致造成的
网站项目Page声明是CodeFile,c# Web应用的Page声明是CodeBehind
post.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Post.aspx.cs" Inherits="Post" %>
<%@ Register Src="UserHead.ascx" TagName="UserHead" TagPrefix="uc1" %>
<%@ Register Src="UserLink.ascx" TagName="UserLink" TagPrefix="uc3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body background="images/106.jpg">
<form id="form1" runat="server">
<div>
<table id="TABLE1" border="0" cellpadding="0" cellspacing="0" style="left: 156px;
width: 730px; position: relative; top: -5px; height: 521px" language="javascript" onclick="return TABLE1_onclick()">
<tr>
<td style="width: 100px">
<uc1:UserHead ID="UserHead1" runat="server" />
</td>
</tr>
<tr>
<td style="width: 100px">
<uc2:Userhooder ID="Userhooder1" runat="server" />
<uc3:UserLink ID="UserLink1" runat="server" />
</td>
</tr>
<tr>
<td style="width: 100px; height: 464px;">
<div align="center" style="z-index: 101; left: 38px; width: 683px; position: relative;
top: 82px; height: 297px; color: purple; font-style: normal; font-family: 新宋体; font-variant: normal;">
<br />
<table style="left: -24px; width: 622px; position: relative; top: -11px; height: 348px;">
<tr>
<td style="width: 77px">
</td>
<td style="width: 137px">
<asp:Label ID="Label1" runat="server" Style="left: 7px; position: relative; top: 0px"
Text="用户留言"></asp:Label></td>
</tr>
<tr>
<td style="width: 77px">
<asp:Label ID="Label2" runat="server" Style="position: relative; left: 6px; top: 0px;" Text="留言者:"></asp:Label></td>
<td style="width: 137px" align = "left">
<asp:TextBox ID="TextBox1" runat="server" Style="position: relative; top: 0px; left: 0px;"
ontextchanged="TextBox1_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="留言者名称不能为空!!" Style="position: relative">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 77px; height: 15px" >
<asp:Label ID="Label3" runat="server" Style="position: relative" Text="性 别:"></asp:Label></td>
<td style="width: 137px; height: 15px" align = "left">
<asp:RadioButton ID="RadioButton1" runat="server" Checked="True" GroupName="Group"
Style="position: relative" Text="男" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="Group" Style="position: relative"
Text="女" /></td>
</tr>
<tr>
<td style="width: 77px; height: 30px;">
<asp:Label ID="Label4" runat="server" Style="position: relative" Text="QQ号:"></asp:Label></td>
<td style="width: 137px; height: 30px;" align = "left">
<asp:TextBox ID="TextBox2" runat="server" Style="position: relative; left: 0px; top: 1px;"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox2"
ErrorMessage="用户QQ号不能为空!!" Style="position: relative">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 77px">
<asp:Label ID="Label5" runat="server" Style="position: relative" Text="Email信箱:" Width="91px"></asp:Label></td>
<td style="width: 137px" align = "left">
<asp:TextBox ID="TextBox3" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 77px; height: 104px;">
<asp:Label ID="Label7" runat="server" Style="position: relative; left: -44px; top: -67px;" Text="留言内容:"></asp:Label></td>
<td style="width: 137px; height: 104px;" valign = "baseline">
<asp:TextBox ID="TextBox4" runat="server" Height="85px" Style="position: relative; left: -103px; top: 3px;"
TextMode="MultiLine" Width="209px"></asp:TextBox>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" Style="left: 125px;
position: relative; top: -84px" Width="149px" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox4"
ErrorMessage=" 发帖内容不能为空!!" Style="left: 23px; position: relative; top: -140px">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 77px">
</td>
<td style="width: 137px">
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Button1" runat="server" Style="position: relative; left: -31px; top: 0px;" Text=" 提交 " OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Style="position: relative; left: 0px; top: 0px;" Text=" 重置 " OnClick="Button2_Click" /></td>
</tr>
<tr>
<td style="width: 77px">
</td>
<td style="width: 137px">
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
</tr>
</table>
</div>
</form>
</body>
</html>