Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have read a lot of articles on how to encrypt and decrypt query string but can't seems to find any on how to use it in html tag. This is what i'm trying to achieve The product id is an interger but i don't want to send it to the SingleProduct.aspx page like that. I want to encrypt it and then decrypt it on the page to make it of it for other operation


What I have tried:

<a href="Singleproduct.aspx?Product=<%#Eval("Product_Id")) %>">
Posted
Updated 15-May-17 23:19pm

1 solution

First of all, you haven't shown us what you already have tried and what is the issue with what have you tried already.

Suggestion -1: If you want to encrypt the querystring
Encrypting Query Strings[^]
Encrypt and Decrypt QueryString Parameter Values in ASP.Net using C# and VB.Net[^]
Asp.Net Encrypt and Decrypt QueryString Parameter Values in C#, VB.NET - ASP.NET,C#.NET,VB.NET,JQuery,JavaScript,Gridview[^]

Suggestion -2: If you don't want to reveal the querystring at all in the URL
Ways to Pass Data Between Webforms! - Haissam [MCAD][^]
How to: Pass Values Between ASP.NET Web Forms Pages[^]

Follow an example as per your requirement and let us know if you face any issue implementing it, we'll try to help you out.

Hope, it helps :)
 
Share this answer
 
Comments
Mcbaloo 16-May-17 6:01am    
The links were a good but what i noticed is that the query string where encryted in the .cs file. The difference in all the solutions and what i am trying to do is that my query string is placed in and not within a button where i can use Response.Redirect.....
Richard Deeming 16-May-17 10:19am    
It's perfectly possible to call a code-behind function within a data-binding expression:
<a href="Singleproduct.aspx?Product=<%# EncryptValue(Eval("Product_Id", "{0}")) %>">


You just need to make sure the function is either public or protected; you can't call a private function.

But you're probably not going to get a lot of benefit from encrypting a single integer.
Suvendu Shekhar Giri 16-May-17 11:16am    
Thanks @Richard for replying. It makes perfect sense.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900