all groups > asp.net webcontrols > november 2003 >
You're in the

asp.net webcontrols

group:

asp:HyperLinkColumn



asp:HyperLinkColumn TJS
11/29/2003 3:17:12 PM
asp.net webcontrols: how can I encrypt the querystring values for a HyperLinkColumn ?

in example below I would like to encrypt value for field1
======================================================
<asp:HyperLinkColumn Text="View" DataNavigateUrlField="field1"
DataNavigateUrlFormatString="page.aspx?idx={0}"></asp:HyperLinkColumn>


asp:HyperLinkColumn Sink
11/30/2003 11:49:32 PM
One way of doing this is to convert from a hyperlink to
a button column, they appear the same. Add an
OnItemCommand handler and in the OnItemCommand handler,
encrypt your id using whatever method you choose and the
call Response.Redirect("....?id=" + EncrytptedValue");
You have to extract the id from the e parameter wen the
OnItemCommand is called.
If you are using paging, make sure you add a check for the
pager in your OnItemCommand handler (the pager is just
another ListItem)or paging will no longer work, especially
as you are changing pages.
On your receiving page side, you decrypt your id and
forward you go.
The OnItemCommand is defined within the datagrid definition
and the check line for the OnItemCommand Handler

if(e.Item.ItemType == ListItemType.Pager)
return;

Hope this helps,
Sink

[quoted text, click to view]
Re: asp:HyperLinkColumn TJS
12/1/2003 9:14:27 AM
thanks for responding.

unfortunately, that would encrypt the value after it is displayed in the
form.
The encryption needs to prevent display at anytime.




[quoted text, click to view]

Re: asp:HyperLinkColumn SInk
12/1/2003 10:19:27 AM
If you keep the actual key in a non-visible field, a bound
column with Visible=False, display some other field,
your requirements would be met.
You would extract the key field from the hidden field
in the handler.

Alternatively, though if the field is hidden, you could
encrypt the key in a seperate db field, using say SHA, and
then use the encrypted field in your hidden field and
save the decrypt on the second page.

Regards
Sink



[quoted text, click to view]
AddThis Social Bookmark Button