如何将SqlDataReader字符串转换为掩码的密码字符串

时间:2019-04-08 15:03:41

标签: javascript c# asp.net sqldatareader

如何将SqlDataReader读取的字符串转换为这样的掩码密码字符串:***** 我不是在尝试将输入或文本框字段更改为类型密码字段,而是在将字符串显示在表中之前更改字符串的显示。我在静态List方法中有一个存储过程,该方法通过ajax函数从数据库读取值,该ajax函数将数据转换为jSon字符串,然后在表中查看。 最好从后面的代码中屏蔽密码,还是应该在javascript ajax函数中进行屏蔽,还是可以屏蔽表本身上的密码-在表标题字段中?

方法:

private static List<MyList> LoadData()
    {
    List<MyList> myObjects = new List<MyList>();
    //Read data from DB using SqlDataReader:
    ...
    myObjects.Password = rdr["Password"].ToString(); // Should I mask the password here?
    ...
    return myObjects;
}


    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public static object GetData()
    {
    List<MyList> data = ModifyMember.LoadData();
    }

Ajax函数:

var Table = $('#TableId').DataTable({

    "processing": true,
    "serverSide": true,
    "ajax": {
        "url": "ModifyMember.aspx/GetData",
        "contentType": "application/json",
        "type": "GET",
        "dataType": "JSON",
        "data": function (d) {
            return d;
        },
        "dataSrc": function (json) {
            json.draw = json.d.draw;
            json.recordsTotal = json.d.recordsTotal;
            json.recordsFiltered = json.d.recordsFiltered;
            json.data = json.d.data;

            var return_data = json;
            return return_data.data;
        }
    },
    "columns": [{
        "data": "Password" // Should I mask the password here?
    }

});

表格:

<table id="TableId">
 <thead>
  <tr>                                    
   <th>Password</th> <%-- Or can I mask the password here --%>
  </tr>
 </thead>
</table>

0 个答案:

没有答案
相关问题