1

我有一个 asp.net mvc,它从控制操作中获取模型数据。我看到 model.genericpassword 字段是空字符串,但在视图中它显示了一个电子邮件地址(仅在 chrome 中)。此电子邮件地址来自此视图之前的登录页面。是缓存问题还是什么?如果我使用 Html.passwordfor,那么它会显示空文本框(这是我想要的)。但我想使用 html.textboxfor 以纯格式显示密码。此问题不在 Firefox 或 IE 中。如果模型具有价值,则它显示正确的价值。

控制器动作是

 [Authorize]
        public ActionResult EditMyUserDetails()
        {
            // IMS.ManagerObjects.IUserProfileManager mgr = profilemanager; //Roopa 29 Oct 2012
            using (IUserProfileManager profilemanager = new ManagerFactory().GetUserProfileManager())
            { //Roopa 29 Oct 2012
                UserProfile profile = profilemanager.GetProfile(CurrentUser.Id, CurrentAccount.Id);
                UserModel model = userauthenticationmanager.GetModelWithProfileInfo(CurrentUser, profile);

                 model.PasswordReminder = model.PasswordReminder != null ? model.PasswordReminder : "";
                 model.GenericPassword = model.GenericPassword != null ? model.GenericPassword : "";


                string[] userTypes = new string[] { "Admin", "Standard User" };
                ViewData["userTypes"] = new SelectList(userTypes, model.myRole.RoleName);



                using (ICurrencyManager currencyManager = new ManagerFactory().GetCurrencyManager())
                {
                    List<Currency> currencies = currencyManager.GetAll().ToList();
                    int currencyId = CurrentAccount.Currency.Id;
                    Currency currency = currencyManager.GetById(currencyId);
                    ViewData["currencies"] = new SelectList(currencies, "DialPrefix", "CountryDialPrefix", currency.DialPrefix);
                }

                return View(model);
            }
        }

and view is:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/child.Master" Inherits="System.Web.Mvc.ViewPage<IMS.Model.UserModel>" %>

<asp:Content ID="contentHead" ContentPlaceHolderID="PageHead" runat="server">
    <script src="../../Content/custom-js/EditMyUserDetails.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContainer" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {

            $("#frmEditMyDetails :input").not(":button").change(function () {
                IsChanged(true);
            });

           $("#dialog-confirm").dialog({
               autoOpen: false,
                resizable: true,
                modal: true,
                buttons: {
                    "Yes": function () {
                        save();
                    },
                   No: function () {
                        document.location.href = $(this).data('Parameter').address;
                        $(this).dialog("close");
                   }
                }
           });
       });
    </script>
    <style type="text/css">
        .wide
        {
            width: 400px;
        }

        .disabled
        {
            background-color: #ebebe4;
        }

        .widetextarea
        {
            width: 400px;
            height: 100px;
        }

        .normal
        {
            width: 317px;
        }

        .small
        {
            width: 40px;
        }
        .tiny
        {
            width: 25px;
        }
    </style>
    <div id="dialog-confirm" title="Do you want to save changes?" style="display: none;">
        <p>
            <span class="ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>Changes
            made to user details are not saved.Do you want to save ?</p>
    </div>
    <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm("EditMyUserDetails", "Account", FormMethod.Post, new { id = "frmEditMyDetails", name = "frmEditMyDetails" }))
       { %>
    <%= Html.ValidationSummary(true)%>
    <%= Html.HiddenFor(model => model.id)%>
    <table>
        <tr>
            <td style="width: 710px;">
                <table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">                  
                    <tr>
                        <td>
                            Email :
                        </td>
                        <td style="padding-left: 1px">
                            <%= Html.TextBoxFor(model => model.Email, new { @class = "textarea", @disabled ="disabled", @readonly = "readonly", MaxLength = "50" })%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Landline :
                        </td>
                        <td style="padding-left: 1px">
                            <%= Html.TextBoxFor(model => model.Landline, new { @class = "textarea", MaxLength = "50" })%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Mobile :
                        </td>
                        <td style="padding-left: 1px">
                            <%= Html.TextBoxFor(model => model.Mobile, new { @class = "textarea", MaxLength = "50" })%>
                        </td>
                    </tr>            
                    <tr>
                        <td>
                            Generic Password :
                        </td>
                        <td  style="padding-left: 1px">
                            <%= Html.TextBoxFor(model => model.GenericPassword, new { @class = "textarea editable", MaxLength = "50" })%>

                        </td>
                    </tr>
                    <tr>
                        <td>
                            Add generic password by default :
                        </td>
                        <td style="padding-left: 0px">
                           <%-- <%= Html.CheckBox("defaultGeneric")%>--%>
                             <%= Html.CheckBoxFor(model => model.IsGenericDefault )%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Prompt for unique password by default :
                        </td>
                        <td style="padding-left: 0px">
                            <%--<%= Html.CheckBox("PromptForPass")%>--%>
                             <%= Html.CheckBoxFor(model => model.IsUniqueDefault )%>
                        </td>
                    </tr>
                  <%--  <tr>
                        <td>
                            Do not add a password by default :
                        </td>
                        <td style="padding-left: 0px">
                            <%= Html.CheckBox("Defaultpass")%>
                        </td>
                    </tr>--%>
                    <tr>
                        <td colspan="2">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Login Password :
                        </td>
                        <td>

                            <%=Html.PasswordFor(model => model.Password, new { @class = "textarea  editable" })%>
                            <%=Html.HiddenFor(model => model.HiddenPassword)%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            New Password :
                        </td>
                        <td>
                            <%=Html.PasswordFor(model => model.NewPassword, new { @class = "textarea editable" })%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Confirm Password :
                        </td>
                        <td>
                            <%=Html.PasswordFor(model => model.ConfirmPassword, new { @class = "textarea editable" })%>
                        </td>
                    </tr>
                    <tr style="height: 10px;">
                        <td colspan="2">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <b>Please enter some text which will help you remember your password</b>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Password Reminder :
                        </td>
                        <td>
                            <%=Html.TextBoxFor(model => model.PasswordReminder, new { @class = "textarea  editable" })%>
                        </td>
                    </tr>
                </table>
            </td>           
        </tr>
    </table>
    <% } %>
</asp:Content>

此页面上还有其他文本框可以正常工作。

4

0 回答 0