Click here to Skip to main content
15,886,080 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i have two anchor tags on my html page first is like <<a href="/KB/answers/Default.aspx"?cat=shoes">Choose Category and second one is like <<a href="/KB/answers/Default.aspx"?area=california">Choose Area

when user click on first link URL will become something like this Default.aspx?cat=shoes . Actually what i want is when user will click on second Link the URL will be same like first and it will add area querystring to the first url... url should become something like this default.aspx?cat=shoes&area=california..

Any help will be appreciated..
Posted
Comments
Sampath Lokuge 3-Oct-13 9:47am    
Do you need to put hard coded query string values or those are get dynamically according to some condition ?
Harpreet_125 3-Oct-13 9:50am    
i am binding dynamically with anchor tag..
saguptamca 3-Oct-13 10:25am    
Add runat server attribute to anchor tags, and perform string operations whatever u want

Take one class level static variable for querystring.
And use it for manipulating it.
C#
static string Qstring = "default.aspx?";
bool ifBoth = false;
//here check whether both are selected or not and manipulate ifBoth as per selection

    if (ifBoth)
    {
        Qstring += (("cat" + valueForCategory) + ("&Area" + valueForArea));
    }
    else
    {
        if (CategoryChoosen)
        {
            Qstring += ("cat" + valueForCategory);
        }
        else if(AreaChoosen)
        {
            Qstring += ("Area" + valueForArea);
        }
    }


Hope This Help
------------------
Pratik Bhuva
 
Share this answer
 
Hey there,

Try this:
change your a elements to this.
XML
<a id="aCat" href="default.aspx?cat=shoes" runat="server">Choose Category</a>
            <a id="aArea" href="default.aspx?area=california" runat="server">Choose Area</a>

and on Page_Load event of the page, add this code, it will add cat QueryString to the second link when first link is clicked, if its not already added.
and I suppose that default.aspx is the same page where your links exist:
C#
if (Request.QueryString["cat"] != null)
                {
                    if (!aArea.HRef.Contains("cat="))
                    {
                        aArea.HRef = aArea.HRef + "&cat=" + Request.QueryString["cat"].ToString();
                    }
                }

Hope this is what you were looking for, do let me know if it works for you.

Azee...
 
Share this answer
 

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