Encrypting search box text client side before redirecting to results page

Upsepedes

New Member
I'm working on an existing application that is going through UI changes and I'm trying to move the search box functionality to the client. As it is currently, the search box has a search button that OnClick triggers a server side method that looks at the text in the search box set's it to a query string of the search results url and redirects to that url. Because the data in the search box is sensitive the query string value is encrypted server side before redirecting. The existing code is like this:\[code\]<asp:TextBox ID="txtSecretSearch" runat="server" Placeholder="Secret Search"/><asp:Button ID="btnSearch" Text="Search" OnClick="btnSearch_Click" runat="server" />protected void btnSearch_Click(object sender, EventArgs e) { if(txtSecretSearch.Text.ToLower() != "secret search" && !string.IsNullOrEmpty(txtSecretSearch.Text)) Response.Redirect("~/SecretSearchResults.aspx?secret=" + Encryption.EncryptForQueryString(txtSecretSearch.Text)); else Response.Redirect("~/SecretSearchResults.aspx");}\[/code\]Now the new UI design eliminates the search button. Can I move this to the client and achieve the same functionality?I was thinking of using jquery to listen for the enter key and then redirect using something like:\[code\]$("#txtSecretSearch").keyup(function(event){ if(event.keyCode == 13){ window.location = "~/SecretSearchResults.aspx?secret=" + SomeWayToEncrypt($("txtSecretSearch").val()); }});\[/code\]Does this make sense to do? If so, what's a good way to encrypt client side. If not, how do I trigger the server side method when the Enter key is pressed. (Note: I did attempt to use an asp:Panel and use default button and set it to the existing button after giving it visibility false. This only worked in firefox and I need it to work in chrome, ff, and IE 7 and up.)Thank you
 
Back
Top