<td align="left" width="15%" class="body_txt" style="padding-right: 2px; padding-left: 25px;">
<asp:Label ID="lblFirstName" runat="server" Text="First Name:"></asp:Label>
</td>
<td width="35%" align="left" style="padding-left: 25px;">
<asp:TextBox ID="txtFirstName" Width="175px" MaxLength="50" runat="server" CssClass="txt_bx"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidatorFirstName" ControlToValidate="txtFirstName"
SetFocusOnError="true" runat="server" ErrorMessage="*" EnableClientScript="true" ValidationExpression="([a-z]|[A-Z])*"
ForeColor="Black"></asp:RegularExpressionValidator>
</td>
<td width="15%" class="body_txt" align="left" style="padding-right: 2px; padding-left: 25px;">
<asp:Label ID="lblLastName" runat="server" Text="Last Name:"></asp:Label>
</td>
<td width="35%" align="left" style="padding-left: 25px">
<asp:TextBox ID="txtLastName" Width="175px" MaxLength="50" runat="server" CssClass="txt_bx"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidatortxtLastName" EnableClientScript="true" ControlToValidate="txtLastName"
SetFocusOnError="true" runat="server" ErrorMessage="*" ValidationExpression="([a-z]|[A-Z])*"
ForeColor="Black"></asp:RegularExpressionValidator>
</td>
当我在 Response.Redirect 之后进入此页面时,我的验证工作正常
但是,在 Server.Transfer 到此页面验证停止工作并且表单在按钮单击时进行回发之后
上一页背后的代码:
protected void btnEdit_Click(object sender, EventArgs e)
{
try
{
for (int i = 0; i < lstEmployee.Rows.Count; i++)
{
GridViewRow row = lstEmployee.Rows[i];
bool isChecked = ((RadioButton)row.FindControl("RowSelector")).Checked;
if (isChecked)
{
iEmployeeId = Convert.ToInt32(row.Cells[0].Text);
hdnEmployeeId.Value = Convert.ToString(iEmployeeId);
Server.Transfer("EmployeeMaint.aspx", true);
}
}
}
登陆页面背后的代码:
protected void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (iEmployeeId != 0)
{
UpdateEmployeeDetails(iEmployeeId);
Response.Write("<script> alert('User Updated sucessfully. ');window.location.href='Employee.aspx'; </script> ");
}
else
{
InsertEmployeeDetails();
Response.Write("<script> alert('User Added sucessfully. ');window.location.href='Employee.aspx'; </script> ");
}
}