2012-10-12 34 views
1

我在我的網站(edituser.aspx)中有一個編輯用戶頁面。用戶名和密碼被放置在一個Access數據庫中,並在FormView中顯示它們。像這樣: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 

回答

1

嘗試評估和演示,而不是綁定:

<%# Decrypt(Eval("passwordID")) %> 
+0

如果我從交換機綁定到Eval。錯誤會增加:沒有給出一個或多個必需參數的值。 –