新手关于注册页面设计的问题

graygift 2008-06-06 04:00:40
这学期期末要做网页作业,在做用户注册页面时,使用多个验证控件时发现不能使错误提码紧跟文本框中间出现一大块上一验证控件的空白。。请各位专家帮忙。。谢谢!!!
...全文
229 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
graygift 2008-06-09
  • 打赏
  • 举报
回复
哦,谢了!
amandag 2008-06-08
  • 打赏
  • 举报
回复
还有楼主你可以使用RequiredFieldValidator,这样你的代码

if (TextBox1.Text == "")
{
Response.Write(" <script>alert('请输入用户名') </script>");
}
else
{
if (TextBox2.Text == "")
{
Response.Write(" <script>alert('请输入密码') </script>");
}
else
{
if (TextBox3.Text != TextBox2.Text)
{
Response.Write(" <script>alert('请输入正确的密码') </script>");
}

else
{
if (TextBox7.Text == "")
{
Response.Write(" <script>alert('请输入密码查询问题') </script>");
}
else
{
if (TextBox4.Text == "")
{
Response.Write(" <script>alert('请输入密码查询答案') </script>");
}
else
{
if (TextBox5.Text == "")
{
Response.Write(" <script>alert('请输入安全邮箱') </script>");
}
else
{
全都可以不要
amandag 2008-06-08
  • 打赏
  • 举报
回复
设置所有的验证控件
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Display="Dynamic" ...></asp:RegularExpressionValidator>
graygift 2008-06-08
  • 打赏
  • 举报
回复
问题我是新手还不懂怎么写CSS啊,而且我还没学会怎么在vs20005中加入CSS。
graygift 2008-06-07
  • 打赏
  • 举报
回复
graygift 2008-06-07
  • 打赏
  • 举报
回复
code=C#]using System;
using System.Data;
using System.Data.OleDb;//1.引入
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{
Response.Write("<script>alert('请输入用户名')</script>");
}
else
{
if (TextBox2.Text == "")
{
Response.Write("<script>alert('请输入密码')</script>");
}
else
{
if (TextBox3.Text != TextBox2.Text)
{
Response.Write("<script>alert('请输入正确的密码')</script>");
}

else
{
if (TextBox7.Text == "")
{
Response.Write("<script>alert('请输入密码查询问题')</script>");
}
else
{
if (TextBox4.Text == "")
{
Response.Write("<script>alert('请输入密码查询答案')</script>");
}
else
{
if (TextBox5.Text == "")
{
Response.Write("<script>alert('请输入安全邮箱')</script>");
}
else
{
//2.建立连接
OleDbConnection mycon = new OleDbConnection();
mycon.ConnectionString = "provider = microsoft.jet.oledb.4.0;data source = " + Server.MapPath(".") + @"\app_data\Database.mdb";
//3.建立数据命令
OleDbCommand mycmd = new OleDbCommand();
mycmd.Connection = mycon;
mycmd.CommandText = "insert into t_member (f_username ,f_password,f_sex, f_Email ,f_fasswordquestion ,f_questionkey ,f_style ) values ('"
+ TextBox1.Text + "','" + TextBox2.Text + "','" + RadioButtonList1.SelectedValue + "','" + TextBox5.Text + "','" + TextBox7.Text + "','" + TextBox4.Text + "','会员')";
//4、打开连接
mycon.Open();

//5、执行数据命令
mycmd.ExecuteNonQuery();
Response.Write("<script>alert('注册成功!');</script>");
}
}
}
}
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";

TextBox7.Text = "";
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Write("<script>window.open ('./clause.aspx') </script> ");

}
}

[/code]
以上就是我新做的代码啊!!
graygift 2008-06-07
  • 打赏
  • 举报
回复
昨晚我又做了适当的修改
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserRegister.aspx.cs" Inherits="_Default" %>
<!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>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body style="font-family: 宋体">
<form id="form1" runat="server">
<div>
<div style="z-index: 101; left: 229px; width: 760px; position: absolute; top: 59px;
height:800px; text-align: center" id="a">
<table style="width: 90%; height: 687px; border-left-color: gray; border-right-style: solid; border-left-style: solid; border-right-color: gray; border-bottom-color: gray; border-top-style: solid; border-top-color: gray; border-bottom-style: solid;">
<tr>
<td colspan="3" style="width: 25%; border-bottom: gray thin dashed; text-align: right">
<h1 style="text-align: center">
<span style="margin-top: 2px; font-size: 2em; margin-bottom: 3px; vertical-align: middle;
border-bottom: gray thin dotted; font-family: 黑体, 新宋体; position: static; text-align: center">
用户注册</span></h1></td>
</tr>
<tr>
<td style="width: 25%; text-align: right;">
<asp:Label ID="Label6" runat="server" ForeColor="Red" Text="*"></asp:Label>用户名:</td>
<td style="width: 40%; border-top-width: thin; border-top-color: #cccccc; text-align: left; border-bottom: gray thin dashed;">
<asp:TextBox ID="TextBox1" runat="server" MaxLength="16"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="错误" ValidationExpression="^[a-zA-Z][a-zA-Z0-9_]{3,15}$"></asp:RegularExpressionValidator>
</td>
<td style="width: 40%; border-top-width: thin; border-bottom-width: thin; border-bottom-color: gray; border-top-color: gray; text-align: left;">
<asp:Label ID="Label1" runat="server" Text="登录名:字母开头,4-16个字符(包括4、16), 请用英文小写、汉字、数字."></asp:Label></td>
</tr>
<tr>
<td style="width: 25%; text-align: right;">
<asp:Label ID="Label7" runat="server" ForeColor="Red" Text="*"></asp:Label>输入登录密码:</td>
<td style="width: 40%; text-align: left;">
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password" MaxLength="16"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox2"
ErrorMessage="错误" ValidationExpression="[a-zA-Z0-9_]{5,15}$"></asp:RegularExpressionValidator>
</td>
<td rowspan="2" style="border-top-width: thin; border-bottom-width: thin; border-bottom-color: gray;
width: 40%; border-top-color: gray; text-align: left;">
<asp:Label ID="Label2" runat="server" Text="密码为6—16位(包括6、16),限用英文、数字和下划线,区分大小写"></asp:Label></td>
</tr>
<tr>
<td style="width: 25%; text-align: right; height: 43px;">
<asp:Label ID="Label8" runat="server" ForeColor="Red" Text="*"></asp:Label>再次输入密码:</td>
<td style="width: 40%; text-align: left; height: 43px;">
<asp:TextBox ID="TextBox3" runat="server" TextMode="Password" MaxLength="16"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox3"
ControlToValidate="TextBox2" ErrorMessage="错误"></asp:CompareValidator>
</td>
</tr>
<tr>
<td style="width: 25%; text-align: right; height: 50px;">
<asp:Label ID="Label9" runat="server" ForeColor="Red" Text="*"></asp:Label>
 登录人性别:</td>
<td style="width: 40%; border-top: gray thin dashed; border-bottom: gray thin dashed; text-align: left; height: 50px;">
 <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
Width="150px">
<asp:ListItem Selected="True">男</asp:ListItem>
<asp:ListItem>女</asp:ListItem>
</asp:RadioButtonList></td>
<td style="width: 40%; border-top-width: thin; border-bottom-width: thin; border-bottom-color: gray; border-top-color: gray; height: 50px; text-align: left;">
<asp:Label ID="Label5" runat="server" Text="请登录者输入性别"></asp:Label></td>
</tr>
<tr>
<td style="width: 25%; text-align: right;">
<asp:Label ID="Label10" runat="server" ForeColor="Red" Text="*"></asp:Label>密码查询问题:</td>
<td style="width: 40%; height: 40px; text-align: left;">
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox></td>
<td rowspan="2" style="border-top-width: thin; border-bottom-width: thin; border-bottom-color: gray;
width: 40%; border-top-color: gray; text-align: left;">
<asp:Label ID="Label3" runat="server" Text="查询答案:6个字母、数字、空格(空格不能在首尾)或3个汉字以上(包括6个)。"></asp:Label></td>
</tr>
<tr>
<td style="width: 25%; text-align: right;">
<asp:Label ID="Label11" runat="server" ForeColor="Red" Text="*"></asp:Label>密码查询答案:</td>
<td style="width: 40%; text-align: left;">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 25%; text-align: right;">
<asp:Label ID="Label12" runat="server" ForeColor="Red" Text="*"></asp:Label>安全邮箱:</td>
<td style="width: 40%; text-align: left;">
<asp:TextBox ID="TextBox5" runat="server" Width="151px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="TextBox5"
ErrorMessage="错误" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
<td style="width: 40%; border-top-width: thin; border-bottom-width: thin; border-bottom-color: gray; border-top-color: gray; text-align: left;">
<asp:Label ID="Label4" runat="server" Text="忘记密码时,可凭安全邮箱索取密码。"></asp:Label></td>
</tr>
<tr>
<td style="width: 25%; text-align: right; border-top-width: thin; border-bottom-width: thin; border-bottom-color: gray; border-top-color: gray;">
<asp:Label ID="Label13" runat="server" ForeColor="Red" Text="*"></asp:Label></td>
<td style="width: 40%; border-top: gray thin dashed; border-bottom-width: thin; border-bottom-color: gray; text-align: left;">
<asp:CheckBox ID="CheckBox1" runat="server" Checked="True" Text="我已经看过并同意" /><br />
 <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">《用户注册条款》</asp:LinkButton></td>
<td style="width: 40%; border-top-width: thin; border-bottom-width: thin; border-bottom-color: gray; border-top-color: gray;">
</td>
</tr>
<tr>
<td colspan="3" style="border-top: gray thin dashed; border-bottom-color: gray; width: 25%;text-align: center; border-bottom-style: none">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="提 交" /> 
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="重 置" />
</td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>

说字数超过了我也只能这样了!!!
只在此山中 2008-06-07
  • 打赏
  • 举报
回复
要调整,要不你贴代码出来吧.
rangeon 2008-06-07
  • 打赏
  • 举报
回复
用CSS控制吧

16,721

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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