我第一次编写一些 ASP.NET 代码时偶然发现了一个奇怪的错误。当我单击按钮发布时,它会这样做,但没有任何参数。
代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="SingTelAPI.Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<table style="width:100%;">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<table style="width:100%;">
<tr>
<td>
</td>
<td align="center">
<asp:Label ID="Label4" runat="server" Text="Login" Font-Bold="True"
Font-Names="Verdana" ForeColor="#CC0000" Font-Size="Large"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Panel runat="server" DefaultButton="SubmitBtn" ID="Panel1">
<table style="width:100%;">
<tr>
<td class="style1">
<asp:Label ID="Label9" runat="server" Font-Bold="True" Font-Names="Verdana"
ForeColor="#0066FF" Text="Inupt Details:"></asp:Label>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td class="style1">
<asp:Label ID="Label5" runat="server" Text="Email:"></asp:Label>
</td>
<td>
<telerik:RadTextBox ID="Email" runat="server" Skin="Default">
</telerik:RadTextBox>
</td>
<td>
<asp:CustomValidator ID="EmailValidator" runat="server"
ErrorMessage="Please Enter Email" Font-Bold="True" Font-Names="Verdana"
ForeColor="#00CC66" ControlToValidate="Email" ValidateEmptyText="True"
ValidationGroup="LoginValidation"></asp:CustomValidator>
</td>
</tr>
<tr>
<td class="style1">
<asp:Label ID="Label6" runat="server" Text="Password:"></asp:Label>
</td>
<td>
<telerik:RadTextBox ID="Password" Runat="server" Skin="Default">
</telerik:RadTextBox>
</td>
<td>
<asp:CustomValidator ID="PasswordValidator" runat="server"
ControlToValidate="Password" ErrorMessage="Please Enter Password" Font-Bold="True"
Font-Names="Verdana" ForeColor="#00CC66" ValidateEmptyText="True"
ValidationGroup="LoginValidation"></asp:CustomValidator>
</td>
</tr>
<tr>
<td class="style1" colspan="3">
<hr /></td>
</tr>
<tr>
<td class="style1">
<telerik:RadButton ID="SubmitBtn" runat="server"
Skin="Default" Text="Login" ValidationGroup="LoginValidation"
Width="120px">
</telerik:RadButton>
</td>
<td>
<asp:Label ID="ResultsLabel" runat="server" ForeColor="#339933"></asp:Label>
</td>
<td>
</td>
</tr>
</table>
</asp:Panel>
</td>
<td>
</td>
</tr>
</table>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</asp:Content>
和 .cs 文件:
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string email = HttpContext.Current.Request["Email"];
Label9.Text = email;
}
}
}
由于某种原因,它会将 Label9 的文本更改为“”。首先我认为问题在于我没有安装telerik,所以我安装了它。但这并没有改变任何事情。