【问题标题】:ChangePassword Control Ignores Custom Template and Renders DefaultChangePassword 控件忽略自定义模板并呈现默认值
【发布时间】:2020-03-18 00:26:39
【问题描述】:

在一些旧代码中,我最近遇到了一个呈现奇怪的ChangePassword 控件。尽管有一个引导布局,但它在一个完全没有布局的表中呈现。

<asp:ChangePassword
    ID="ChangePassword3"
    runat="server">
    <ChangePasswordTemplate>
        <div class="form-row">
            <div class="col-sm-6">
                <asp:Label ID="Label1" runat="server" AssociatedControlID="CurrentPassword">Current Password:</asp:Label>
            </div>
            <div class="col-sm-6">
                <asp:TextBox ID="CurrentPassword" runat="server" TextMode="Password" />
            </div>
        </div>
        <div class="form-row">
            <div class="col-sm-6">
                <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label>
            </div>
            <div class="col-sm-6">
                <asp:TextBox ID="NewPassword" runat="server" TextMode="Password" />
                <%=TestMessage%>
            </div>
        </div>
        <div class="form-row">
            <div class="col-sm-6">
                <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label>
            </div>
            <div class="col-sm-6">
                <asp:TextBox ID="ConfirmNewPassword" runat="server" TextMode="Password"></asp:TextBox>
            </div>
        </div>
    </ChangePasswordTemplate>
</asp:ChangePassword>

为什么渲染不正确?

【问题讨论】:

    标签: asp.net webforms change-password


    【解决方案1】:

    事实证明,如果不破坏它,就无法在此模板中使用代码渲染块。但是,它会静默中断,没有任何错误指示,然后恢复为默认渲染。删除以下行解决了问题。

    <%=TestMessage%>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      • 2013-04-05
      相关资源
      最近更新 更多