我的网站内有一个编辑用户页面(edituser.aspx)。用户名和密码放在Access数据库中,我在FormView中显示它们。像这样:
<asp:FormView
ID="EditForm"
runat="server"
DefaultMode="Edit">
<EditItemTemplate>
<strong>username:</strong><br />
<asp:TextBox ID="usernameIDTextBox" runat="server" Text='<%# Bind("usernameID") %>' /><br />
<strong>Password:</strong><br />
<asp:TextBox ID="passwordIDTextBox" TextMode="password" runat="server" Text='<%# Bind("passwordID") %>' /><br />
... .
我在数据库中加密了密码但是虽然我有解密功能,但是我不知道如何在绑定短语中使用它。例如我试过
<%# decrypt(Bind("passwordID")) %>
这不起作用。
注意:我使用asp.net 3.5,这是我在edituser.aspx.vb中解密的函数:
Public Function Decrypt(ByVal strDecoded_Pword As String) As String
On Error Resume Next
Dim i, ct As Integer
Dim letter, dec, StrValappend, strVal As String
dec = ""
strDecoded_Pword = StrReverse(strDecoded_Pword)
For ct = 1 To Len(strDecoded_Pword) Step 2
StrValappend = Chr(Val("&H" & (Mid(strDecoded_Pword, ct, 2))))
strVal = strVal & StrValappend
Next
strDecoded_Pword = strVal
For i = 1 To Len(strDecoded_Pword)
letter = Mid(strDecoded_Pword, i, 1)
dec = dec & Chr(Asc(letter) - i - 5)
Next
Decrypt = dec
End Function
答案 0 :(得分:1)
尝试Eval而不是Bind:
<%# Decrypt(Eval("passwordID")) %>