Hello Iman it looks like you are doing this in some user control, maybe a webpart or control? If so you could just replace your:
<a href="http://example.com/products.aspx?lang=en-us&view=grid" class="grid">grid</a>
with just a regular asp:Literal something like this:
<asp:Literal ID="ltlMyLink" runat="server" EnableViewState="false" />
and then in your code behind you can do your logic for this:
if(QueryHelper.GetString("view", "") == "grid")
{
ltlMyLink.Text = @"<a href=""http://example.com//products.aspx?lang=en-us&view=list"" class=""list"">list</a>";
}
else
{
ltlMyLink.Text = @"<a href=""http://example.com//products.aspx?lang=en-us&view=grid"" class=""grid"">grid</a>";
}
of course if you have more than just these two options you should take the value of QueryHelper.GetString("view", "") and maybe do some custom logic with it to get whatever you desired value is to insert in to your URL.