我是asp新手。我已经使用asp建立了一个网站。我使用 Artisteer 构建模板。在我尝试创建登录页面之前,一切正常。我会给我的部分代码不要打扰
这是我的 Registration.aspx 页面的一部分
<@ Page Language="C#" MasterPageFile="~/design/MasterPage.master" AutoEventWireup="true"
CodeFile="Registration.aspx.cs" Inherits="Registration" %>
<@ Import Namespace="Artisteer" %>
<@ Register TagPrefix="artisteer" Namespace="Artisteer" %>
<@ Register TagPrefix="art" TagName="DefaultMenu" Src="DefaultMenu.ascx" %>
<@ Register TagPrefix="art" TagName="DefaultHeader" Src="DefaultHeader.ascx" %>
<@ Register TagPrefix="art" TagName="DefaultSidebar1" Src="DefaultSidebar1.ascx" %>
asp:Content ID="PageTitle" ContentPlaceHolderID="TitleContentPlaceHolder" Runat="Server">Once Upon a Cake</asp:Content>
asp:Content ID="MenuContent" ContentPlaceHolderID="MenuContentPlaceHolder" Runat="Server">
<art:DefaultMenu ID="DefaultMenuContent" runat="server" />
</asp:Content>
asp:Content ID="HeaderContent" ContentPlaceHolderID="HeaderContentPlaceHolder" Runat="Server">
art:DefaultHeader ID="DefaultHeader" runat="server" />
</asp:Content>
asp:Content ID="SideBar1" ContentPlaceHolderID="Sidebar1ContentPlaceHolder" Runat="Server">
art:DefaultSidebar1 ID="DefaultSidebar1Content" runat="server" />
</asp:Content>
<asp:Content ID="SheetContent" ContentPlaceHolderID="SheetContentPlaceHolder" Runat="Server">
<artisteer:article ID="Article2" runat="server"><ContentTemplate>
<br />
<table class="art-article" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>Name</td>
<td>User Name</td>
<td><asp:TextBox ID="textBoxUser" runat="server" Width="240" MaxLength="15" ></asp:TextBox>
</td>
<td>
<td>
…………
Registration.aspx.cs 文件是
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
con.Open();
string cmdStr = "Select coun (*) from Register where UserName='" + textBoxUser.Text + "'";
SqlCommand userExist = new SqlCommand(cmdStr, con);
int temp = Convert.ToInt32(userExist.ExecuteScalar().ToString());
if (temp == 1)
{
Response.Write("User Name already Exist!!! </br> Choose another");
}
}
}
问题是 .cs 文件中无法识别 textBoxUser。有人有什么主意吗?