I'm trying to encrypt the textbox when it sends, what I'm trying to do is get the text encrypt and return the encrypted test to the textbox when the button is pressed, this is the code:
the javascript
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
--all the textbox is here
<asp:Button ID="btnSave" runat="server" CssClass="button" Text="Submit" OnClick="btnSave_Click"></asp:Button>
<script src="../Scripts/jquery-1.10.2.js" ></script>
<script type="text/javascript" language="javascript">
function encrypt(old,new,confirm)
{
if (document.getElementById("<%=txtOldPassword.ClientID%>").value != "")
{
document.getElementById("<%=txtOldPassword.ClientID%>").value = old;
}
if (document.getElementById("<%=txtNewPassword.ClientID%>").value != "")
{
document.getElementById("<%=txtNewPassword.ClientID%>").value = new;
}
if (document.getElementById("<%=txtNewPwdConfirm.ClientID%>").value != "")
{
document.getElementById("<%=txtNewPwdConfirm.ClientID%>").value = confirm;
}
alert("TextBox Value is " + txtOldPassword.value);
}
</script>
</asp:Content>
my javascript inside the asp:content, this is my backend code
protected void btnSave_Click(object sender, EventArgs e)
{
btnSave.Attributes.Add("OnClientClick", "javascript:return encrypt('" + old() + "','" + newpass() + "','" + conf() + "');");
}
private string old()
{
string old = Encrypt(txtOldPassword.Text);
return old;
}
private string newpass()
{
string newpass = Encrypt(txtNewPassword.Text);
return newpass;
}
private string conf() {
string conf = Encrypt(txtNewPwdConfirm.Text);
return conf;
}
why when I try to click the save button the textbox is not encrypted, I try to call the javascript it seems that asp: content does not detect javascript.