奇怪的提交事件!

jeall 2005-03-01 04:12:27
请大家访问:http://job1234.com/Users/Regist.aspx

奇怪的是我在添加信息的时候一点反应都没有,请有经验的朋友帮忙看看!

以下情况排除:
1、page_load
2、按钮的加载事件

以前是因为该网站不支持javascrip语言,现在我去掉了以后,还是不行!

该页面加了基本的验证:用户名不能为空,密码不能为空,2次密码是否正确!

其它页面都没有出现类似的情况!急!
...全文
136 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeall 2005-04-21
  • 打赏
  • 举报
回复
问题查明!
我忽视了最重要的,最明显的细节,对方的网站不支持javascript!
代码没有问题,也执行了!但是瞬间即失!
tongyiyi 2005-03-02
  • 打赏
  • 举报
回复
我也有这个问题,还没解决呢。我点提交,只是页面刷新一次,把密码清空一次!却没有添加记录
jeall 2005-03-01
  • 打赏
  • 举报
回复
谢谢!

我请问,你点击button的那个按钮事件内容显示出来了吗?

我在本地的就都可以,一到网站上就什么都不行了!特奇怪!
Night_Elf 2005-03-01
  • 打赏
  • 举报
回复
我把你的代码考下来执行了一下,发现程序已经进入了Button1_Click这个方法,这说明注册按钮是起作用的,问题一定存在于Button1_Click事件的内部,你单步调试一下,看看他是到了那一步出了问题
jeall 2005-03-01
  • 打赏
  • 举报
回复
谢谢各位了!
Night_Elf 2005-03-01
  • 打赏
  • 举报
回复
/////
经过 注册_Click 事件了吗
/////

这个要怎么查!
-------------------------------
在 注册_Click 事件中设置断点进行单步调试,且现把断点设在server =Dns.GetHostName();这一行
jeall 2005-03-01
  • 打赏
  • 举报
回复
后台:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using System.Configuration;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using System.Net;

namespace HRUnions.Users
{
/// <summary>
/// Regist 的摘要说明。
/// </summary>
public class Regist : System.Web.UI.Page
{
protected string ConnString=ConfigurationSettings.AppSettings["HRUnions"];
protected string SqlStr;
protected System.Web.UI.WebControls.Label ErrMsg;
protected System.Web.UI.WebControls.TextBox UserName;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox PassWord1;
protected System.Web.UI.WebControls.RequiredFieldValidator Pwd1_RequiredFieldValidator2;
protected System.Web.UI.WebControls.CompareValidator CompareValidator1;
protected System.Web.UI.WebControls.TextBox PassWord2;
protected System.Web.UI.WebControls.RequiredFieldValidator Pwd2_RequiredFieldValidator2;
protected System.Web.UI.WebControls.TextBox UserEmail;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
protected System.Web.UI.WebControls.RadioButtonList UserLevel_RdBtn;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!this.Page.IsPostBack )
{
RadioBtnListBind();
}
}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
string ip;

string server = null;
server =Dns.GetHostName();
IPHostEntry heserver = Dns.Resolve(server);
ip = heserver.AddressList[0].ToString().Trim() ;

/*
for (int i=0;i<heserver.AddressList.Length ;i++ )
{
ip += heserver.AddressList[i] ;
}
*/
SqlStr="Select username,userpassword,useremail From Users Where username='"+ this.UserName.Text.Trim() +"' Or userpassword='"+ this.PassWord1.Text.Trim() +"' Or useremail='"+ this.UserEmail.Text.Trim() +"'";
SqlDataReader rd=SqlHelper.ExecuteReader(ConnString,CommandType.Text,SqlStr);
if (rd.HasRows )
{this.ErrMsg.Text="该用户名或密码或Email重复!请重填!";}
else
{
SqlStr="Insert Into Users (username,userpassword,userlevel,userapplydate,userip,userhostname,useremail) Values ";
SqlStr +=" ('"+ this.UserName.Text.Trim() +"','"+ this.PassWord1.Text.Trim() +"',"+ this.UserLevel_RdBtn.SelectedValue;
SqlStr +=",getdate(),'"+ ip.Trim() +"','"+ heserver.HostName.Trim() +"','"+ this.UserEmail.Text.Trim() +"')";

SqlHelper.ExecuteNonQuery(ConnString,CommandType.Text,SqlStr);
this.ErrMsg.Text="添加成功!请重新登录!";
}
}

private void RadioBtnListBind()
{
DataSet objds = SqlHelper.ExecuteDataset(ConnString,CommandType.Text,"Select menunum,menuname From menus Where menuflag=11 And menuparent=1");
this.UserLevel_RdBtn.DataTextField = objds.Tables[0].Columns[1].ToString().Trim();
this.UserLevel_RdBtn.DataValueField = objds.Tables[0].Columns[0].ToString().Trim();
this.UserLevel_RdBtn.DataSource = objds;
this.UserLevel_RdBtn.DataBind();
this.UserLevel_RdBtn.SelectedIndex = 0;
}

private void Button2_Click(object sender, System.EventArgs e)
{
Response.Write ("OK");
this.UserName.Text="NNNNNNN";

}
}
}
jeall 2005-03-01
  • 打赏
  • 举报
回复
前台代码:
<%@ Page language="c#" Codebehind="Regist.aspx.cs" AutoEventWireup="false" Inherits="HRUnions.Users.Regist" %>
<%@ Register TagPrefix="HRUNION" TagName="WebAddress" Src="../Function/WebAddress.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<meta name="vs_showGrid" content="False">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<LINK href="/Css/main.css" type="text/css" rel="stylesheet">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="760" align="center" border="0">
<TR>
<TD align="right" width="200">
<HRUNION:WebAddress id="WebAddress1" runat="server"></HRUNION:WebAddress></TD>
<TD width="560"> 用户注册</TD>
</TR>
</TABLE>
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="760" align="center" border="0">
<TR>
<TD colspan="2" align="center"><font size="3"><b>用 户 注 册</b></font></TD>
</TR>
<tr>
<td align="center">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="400" align="center" border="0">
<TR>
<TD colspan="2" align="center">
<asp:Label id="ErrMsg" runat="server" ForeColor="Red"></asp:Label></TD>
</TR>
<TR>
<TD width="15%">用户名:</TD>
<TD width="85%">
<asp:TextBox id="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="用户名不能为空!" ControlToValidate="UserName"></asp:RequiredFieldValidator></TD>
</TR>
<TR>
<TD>密码:</TD>
<TD>
<asp:TextBox id="PassWord1" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator id="Pwd1_RequiredFieldValidator2" runat="server" ErrorMessage="密码不能为空!" ControlToValidate="PassWord1"></asp:RequiredFieldValidator>
<asp:CompareValidator id="CompareValidator1" runat="server" ErrorMessage="密码不统一!" ControlToValidate="PassWord2"
ControlToCompare="PassWord1"></asp:CompareValidator></TD>
</TR>
<TR>
<TD>确认密码:</TD>
<TD>
<asp:TextBox id="PassWord2" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator id="Pwd2_RequiredFieldValidator2" runat="server" ErrorMessage="确认密码不能为空!" ControlToValidate="PassWord2"></asp:RequiredFieldValidator></TD>
</TR>
<TR>
<TD>Email:</TD>
<TD>
<asp:TextBox id="UserEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="UserEmail" ErrorMessage="Email地址不能为空!"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ControlToValidate="UserEmail" ErrorMessage="Email格式不正确!"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></TD>
</TR>
<TR>
<TD valign="top">用户类别:</TD>
<TD>
<asp:RadioButtonList id="UserLevel_RdBtn" runat="server" RepeatColumns="2"></asp:RadioButtonList></TD>
</TR>
<TR>
<TD></TD>
<TD>
<asp:Button id="Button1" runat="server" Text="注册"></asp:Button>  <INPUT type="reset" value="重写">
<asp:Button id="Button2" runat="server" Text="Button"></asp:Button></TD>
</TR>
</TABLE>
</td>
</tr>
</TABLE>
</form>
</body>
</HTML>
Night_Elf 2005-03-01
  • 打赏
  • 举报
回复
呵呵,还是没大明白,请确定你的前台的button是<asp:Button
xiaohutushen 2005-03-01
  • 打赏
  • 举报
回复
你先检查alert(typeof(Page_ClientValidate) == 'function');

然后在检查你的方法是否正确.Page_ClientValidate()

最好都贴出来.
jeall 2005-03-01
  • 打赏
  • 举报
回复
该有的代码都有了,所以觉得奇怪!

/////
经过 注册_Click 事件了吗
/////

这个要怎么查!
web_gus 2005-03-01
  • 打赏
  • 举报
回复
runat="server"
LoveCherry 2005-03-01
  • 打赏
  • 举报
回复
帖前台代码
页面没有提交
jeall 2005-03-01
  • 打赏
  • 举报
回复
有声明!

我是说如果改成web的部就不是.net写的了吗?我想都用.net的做!
Night_Elf 2005-03-01
  • 打赏
  • 举报
回复
经过 注册_Click 事件了吗
jeall 2005-03-01
  • 打赏
  • 举报
回复
有!
Night_Elf 2005-03-01
  • 打赏
  • 举报
回复
那不就不是C#程序了么?
----------------------------------
没懂你的意思
Night_Elf 2005-03-01
  • 打赏
  • 举报
回复
在前他的注册按钮中是否有 runat="server"
jeall 2005-03-01
  • 打赏
  • 举报
回复
那不就不是C#程序了么?
其它的都可以,就只有哪个1
Night_Elf 2005-03-01
  • 打赏
  • 举报
回复
好像没什么问题呀,设置断点,看看程序是否经过了 注册_Click 事件
检查是否包含protected System.Web.UI.WebControls.Button Button1
加载更多回复(5)

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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