开发者

Encoding Decoding Querystring in ASPX Page

开发者 https://www.devze.com 2023-02-19 17:30 出处:网络
I need to encode querystring from the aspx itself, like we do <%Eval()%>.Below is my html <asp:HyperLinkField HeaderText=\"Your Header\"

I need to encode querystring from the aspx itself, like we do <%Eval()%>.Below is my html

<asp:HyperLinkField HeaderText="Your Header" 
 DataNavigateUrlFields="userId" 
  DataTextField="Your Data Field to Display" 
 HeaderStyle-HorizontalAli开发者_开发百科gn="Center"
  DataNavigateUrlFormatString="mypage.aspx?type=2&userId={0}" 
 ItemStyle-Width="35%"  
 ItemStyle-HorizontalAlign="Left" 
   />

Here i want to encrypt or simply encode the parameters type and userid so that it will look like encrypted.


I am answering my own post, as a help to others.I have achieved the result and posting the result.

Instead of asp:HyperlinkField , used the code below

    <asp:TemplateField HeaderText="Project">
        <ItemTemplate>
           <asp:HyperLink ID="OpenDoc" runat="server" 
NavigateUrl='<%# this.ResolveUrl(string.Format("AddPropertyDetail.aspx?pid={0}&s=1",base64Encode(Eval("PropertyID").ToString()))) %>'
    ToolTip="Click here to open the image" Text='<%#Eval("Area") %>'>' Target="_blank">
           </asp:HyperLink>
      </ItemTemplate>
  </asp:TemplateField>
0

精彩评论

暂无评论...
验证码 换一张
取 消