- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法访问代码隐藏中的任何 asp 控件。 .aspx页面如下
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ChangePassword.aspx.cs" Inherits="ChangePassword" ValidateRequest="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ChangePassword ID="ChangePassword1" runat="server" CssClass="MinutesList"
onchangedpassword="ChangePassword1_ChangedPassword">
<ChangePasswordTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center" colspan="2">
Change Your Password</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="CurrentPasswordLabel" runat="server"
AssociatedControlID="CurrentPassword">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="CurrentPassword" runat="server" TextMode="Password" Visible="false" >></asp:TextBox>
<asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server"
ControlToValidate="CurrentPassword" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="ChangePassword1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="NewPasswordLabel" runat="server"
AssociatedControlID="NewPassword">New Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="NewPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server"
ControlToValidate="NewPassword" ErrorMessage="New Password is required."
ToolTip="New Password is required." ValidationGroup="ChangePassword1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="ConfirmNewPasswordLabel" runat="server"
AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="ConfirmNewPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server"
ControlToValidate="ConfirmNewPassword"
ErrorMessage="Confirm New Password is required."
ToolTip="Confirm New Password is required." ValidationGroup="ChangePassword1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator ID="NewPasswordCompare" runat="server"
ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword"
Display="Dynamic"
ErrorMessage="The Confirm New Password must match the New Password entry."
ValidationGroup="ChangePassword1"></asp:CompareValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right">
<asp:Button ID="ChangePasswordPushButton" runat="server"
CommandName="ChangePassword" Text="Change Password"
ValidationGroup="ChangePassword1" />
</td>
<td>
<asp:Button ID="CancelPushButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</ChangePasswordTemplate>
<SuccessTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center" colspan="2">
Change Password Complete</td>
</tr>
<tr>
<td>
Your password has been changed!</td>
</tr>
<tr>
<td>
<asp:Button ID="HomePageButton" runat="server" Text="Continue" CausesValidation="true"
onclick="HomePageButton_Click" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</SuccessTemplate>
</asp:ChangePassword>
</asp:Content>
代码隐藏是
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ChangePassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//TextBox password = (TextBox)ChangePassword1.FindControl("CurrentPassword");
//Label passwordLabel = (Label)ChangePassword1.FindControl("CurrentPasswordLabel");
TextBox password = ChangePassword1.FindControl("CurrentPassword") as TextBox;
Label passwordLabel = ChangePassword1.FindControl("CurrentPasswordLabel") as Label;
//TextBox CurrentPassword = ChangePassword1.FindControl("CurrentPassword") as TextBox;
if (Request.QueryString["p"] != null)
{
passwordLabel.Visible = false;
password.TextMode = TextBoxMode.SingleLine;
password.Visible = false;
password.Text = Request.QueryString["p"];
}
}
protected void ChangePassword1_ChangedPassword(object sender, EventArgs e)
{
}
protected void HomePageButton_Click(object sender, EventArgs e)
{
//Link.ToHomePage();
Response.Redirect("HomePage.aspx");
}
}
我遇到的问题是我得到的对象引用未设置为 passwordLabel 和密码上的对象实例。有谁知道如何将它们纳入范围,以便我可以在代码隐藏中编辑文本和可见性属性?
最佳答案
尝试使用:
TextBox password = ChangePassword1.Controls[0].FindControl("CurrentPassword") as TextBox;
Label passwordLabel = ChangePassword1.Controls[0].FindControl("CurrentPasswordLabel") as Label;
关于c# - 无法在代码隐藏中访问 asp.net changepassword 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11424716/
我正在开发 Meteor 应用程序,我想将调用转至 Accounts.changePassword从客户端到方法。但是,当我尝试运行该方法时,出现此服务器错误: Exception while inv
我正在尝试使用以下脚本重置密码 /* *@NApiVersion 2.0 *@NScriptType ClientScript */ require(['N/auth'], function(
我们的应用使用 Firebase 简单登录。它似乎工作得很好,包括它们包含的大多数额外调用,如 resetPassword。 changePasswordForEmail 似乎也有效。当用户给它正确的
这个问题已经有答案了: "Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key",
我使用 控件,但我不知道如何将新密码文本和其他字段对齐到左侧而不是右侧。我已经尝试添加一个类并执行 text-align: left , 但对齐仍然在右边。 是否可以左对齐?
MembershipService.ChangePassword 不更改密码问题。我不知道为什么... var userUsers = from n in db.aspnet_Users where
设置:我将 Meteor 1.4.4.2 与 React 和 accounts-password package 一起使用(版本 accounts-base@1.2.17,accounts-passw
我遇到了 mvc4 成员资格问题,我无法像更改用户密码一样 public bool SetNewPassword(string newPassword) { var gener
所以我使用 asp:changePassword 来显示允许用户显示密码的表单;然后我将面板居中放置在屏幕上。但是我想在行之间添加间距/单元格填充:到目前为止我有:
无论我试图向它抛出什么,这里的这个方法总是导致以下异常: var retVal = this.DirectoryEntry.Invoke("ChangePassword", new
我有一个自定义门户与自定义站点集成,使用 Apex/Visualforce。我想在为站点/门户启用的 Visualforce 页面上提供自定义密码更改功能。 Site 静态类方法几乎没有文档记录,在结
我正在处理一个 Razor 项目,需要将现有的用户数据库集成到 SimpleMembership 提供程序数据库架构中。这是通过指定我现有的用户表以及 SimpleMembership API 将哪些
我无法访问代码隐藏中的任何 asp 控件。 .aspx页面如下
我无法访问代码隐藏中的任何 asp 控件。 .aspx页面如下
我有一个应用程序,当用户提示忘记密码时,管理员可以设置用户密码。 我的应用程序使用 (UserPrincipal).SetPassword(newPassword); 并且有效,但它完全忽略策略,并让
我将以下代码作为我的 Active Directory 用户的 Web 应用程序的一部分,以便能够更新他们的密码(同时用于 Active Directory 和 gmail)。我将 C# 与 Syst
DirectoryEntryObject.Invoke("ChangePassword", new object[] { oldPassword, newPassword } ); 抛出以下错误: "
我只是在学习如何加密/解密 SQLite 数据库。 我找到了一种加密方法,如这篇文章 SQLite with encryption/password protection 此页面的最佳答案说我们可以使
我有一个使用 ActiveDirectoryMembershipProvider 进行表单例份验证的 Web 应用程序。效果很好...用户可以成功登录。 用户登录后,可以更改密码。我们使用 Chang
我正在考虑在 ASP.NET 2.0 Webform 上使用 ChangePassword 控件。我不想显示“取消”按钮。 有没有一种好的方法可以隐藏它,而不必诉诸愚蠢的“宽度= 0”之类的游戏? 或
我是一名优秀的程序员,十分优秀!