因为页面报错后,生成了一个中间状态的页面,所以你得返回两次。最好用Redirect()

解决方案 »

  1.   

    好啊。我来贴
    <%@ Page language="c#" Codebehind="cAccountAdd.aspx.cs" AutoEventWireup="false" Inherits="PartnerBill.cAccountAdd" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link rel="stylesheet" href="op.css" type="text/css">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="expires" content="-1">
    <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <body bgcolor="#003399" text="#000000" leftmargin="0" topmargin="0">
    <div align="center">
    <form id="cAccountAdd" method="post" runat="server">
    <input type="hidden" id="hidpID" runat="server">
    <table width="776" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="194"><!--#include file="includes/headinclude.htm"-->
    </td>
    </tr>
    <tr>
    <td background="images/top1.jpg" height="45"><img src="images/yhgl.gif" width="134" height="29"><FONT color="#ffffff"><STRONG>---- 
    </STRONG></FONT></td>
    </tr>
    </table>
    <table class="" width="776" border="0" cellspacing="0" cellpadding="0" bgcolor="#f9f7f8">
    <tr>
    <td align="middle">
    <TABLE id="Table1">
    <tr>
    <td colspan="2" align="middle" style="HEIGHT: 25px">
    <asp:Label id="lbErrMsg" runat="server" Font-Size="X-Small" Font-Bold="True" ForeColor="Red"></asp:Label></td>
    <TD style="HEIGHT: 25px" align="middle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
    </tr>
    <TR>
    <TD style="FONT-SIZE:x-small; HEIGHT:25px">名称</TD>
    <TD>
    <P><INPUT type="text" id="txtcName" name="txtcName" runat="server" maxLength="20"></P>
    </TD>
    <TD>
    <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" Font-Size="X-Small" Font-Bold="True" ErrorMessage="请输入子帐号名" Display="Dynamic" ControlToValidate="txtcName"></asp:RequiredFieldValidator>
    <asp:regularexpressionvalidator id="RegularLogonName" runat="server" Font-Size="X-Small" Font-Bold="True" ForeColor="#FF0000" ErrorMessage="用户名无效,请重新输入" Display="Dynamic" ControlToValidate="txtcName" ValidationExpression="[a-z|A-Z]{1}[\w]{4,19}"></asp:regularexpressionvalidator>
    <asp:customvalidator id="CustomLogonName" runat="server" Font-Bold="True" Font-Size="X-Small" ControlToValidate="txtcName" Display="Dynamic" ErrorMessage="该用户名已经存在,请换一个用户名"></asp:customvalidator></TD>
    </TR>
    <tr>
    <TD style="FONT-SIZE:x-small; HEIGHT:25px">昵称</TD>
    <td>
    <INPUT id="txtNickName" type="text" runat="server" maxLength="30" NAME="txtNickName"></td>
    <TD>
    <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" Font-Size="X-Small" Font-Bold="True" ErrorMessage="请输入昵称" Display="Dynamic" ControlToValidate="txtNickName"></asp:RequiredFieldValidator>
    <asp:regularexpressionvalidator id="RegularNickName" runat="server" Font-Size="X-Small" Font-Bold="True" ForeColor="#FF0000" ErrorMessage="请输入2-30位的字母,数字或中文字符" Display="Dynamic" ControlToValidate="txtNickName" ValidationExpression="[^\x7C\x7B\x7D\x5B\x5D\x5F\x2D\x2B\x3D\x3F\x2F\x3C\x3E\x28\x29\x7E\x60\x22\x27\2C\x2E\x3B\x21\x40\x23\x24\x25\x5E\x26\x2A\s]{2,30}"></asp:regularexpressionvalidator></TD>
    </tr>
    <TR>
    <TD style="FONT-SIZE:x-small; HEIGHT:25px">密码</TD>
    <TD>
    <INPUT id="txtPassword" type="password" name="Password1" runat="server" maxLength="18"></TD>
    <TD>
    <asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" Font-Size="X-Small" Font-Bold="True" ErrorMessage="请输入密码" Display="Dynamic" ControlToValidate="txtPassword"></asp:RequiredFieldValidator>
    <asp:regularexpressionvalidator id="RegularPassword" runat="server" Font-Size="X-Small" Font-Bold="True" ForeColor="#FF0000" ErrorMessage="密码无效,请输入6-18位密码" Display="Dynamic" ControlToValidate="txtPassword" ValidationExpression="[^\s]{6,18}"></asp:regularexpressionvalidator></TD>
    </TR>
    <tr>
    <TD style="FONT-SIZE:x-small; HEIGHT:25px">重输密码</TD>
    <td>
    <INPUT id="txtRePassword" type="password" maxLength="18" runat="server" NAME="txtRePassword"></td>
    <TD>
    <asp:RequiredFieldValidator id="RequiredFieldValidator4" runat="server" Font-Size="X-Small" Font-Bold="True" ErrorMessage="请再输一遍密码" Display="Dynamic" ControlToValidate="txtRePassword"></asp:RequiredFieldValidator>
    <asp:CompareValidator id="CompareValidator1" runat="server" Font-Size="X-Small" Font-Bold="True" ErrorMessage="密码不一致,请重新输入" Display="Dynamic" ControlToValidate="txtRePassword" ControlToCompare="txtPassword"></asp:CompareValidator></TD>
    </tr>
    <tr>
    <td style="FONT-SIZE:x-small; HEIGHT:25px" colspan="2" align="middle">
    <INPUT class="input" id="btnSubmit" type="button" value="提交" runat="server">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button CssClass="input" id="btnReturen" runat="server" Text="返回" CausesValidation="False"></asp:Button></td>
    <TD style="FONT-SIZE: x-small; HEIGHT: 25px" align="middle"></TD>
    </tr>
    </TABLE>
    </td>
    </tr>
    </table>

    </form>
    </div>
    </body>
    </HTML>
      

  2.   

    回复人: BeyondLove2000(马) ( ) 信誉:100  2003-08-27 11:12:00  得分:0 
     
     
      因为页面报错后,生成了一个中间状态的页面,所以你得返回两次。最好用Redirect()
      
     
    这个应该用在哪里啊?
      

  3.   

    服务器端
    private void btnReturen_Click(object sender, System.EventArgs e)
    {
    Session["cAccountListBack"] = "TRUE";
    Response.Redirect("cAccountList.aspx?ParentUserID="+Request.QueryString["pAccountID"].ToString(),true);
    }
      

  4.   

    我调试一下,你的<!--#include file="includes/headinclude.htm"-->由于没有帖出来,我去掉了,不知道有没有影响,
    1所以如果我什么不输入,点提交没有任何提示,点返回到本页了
    2如果我输入,提示密码不对什么的,点返回也返回到本页了,
    没出现你说的问题,为什么呢?
      

  5.   

    提交按纽事件执行完后Response.Redirect("yourweb.aspx",true);
      

  6.   

    第一次运行,如果什么都不输入,不会提示输入用户名,点提交没有反应,但如果我改成提交按钮和文本框都是<asp:...>等服务器控件就可以了
    我建议把这些验证的文本框和提交按钮改成服务器控件<asp:..>形式的,怀疑和这个有关
    然后用Response.Redirect调试一下
      

  7.   

    to xrll() :我不能使用使用客户端事件,因为我必须必须获得一个值,就是那个SESSION值。
    否则,我直接让他window.history.back()了
      

  8.   

    seesea125(雨天)你说的那个办法我试过了,不行啊:( 
    55555