如何使用多个查询字符串 [英] how to play with multiple query strings

查看:65
本文介绍了如何使用多个查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html页面上有两个锚标签,首先是<< a href =Default.aspx?cat = shoes>选择类别,第二个类似于<< a href =Default。 aspx?area = california>选择区域



当用户点击第一个链接URL时,会变成类似Default.aspx?cat = shoes。实际上我想要的是当用户点击第二个链接时,URL将像第一个一样,它会将区域查询字符串添加到第一个网址... url应该变成这样的default.aspx?cat = shoes&area = california ..



任何帮助将不胜感激..

i have two anchor tags on my html page first is like <<a href="Default.aspx?cat=shoes">Choose Category and second one is like <<a href="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..

推荐答案

拿一个类级静态变量 for querystring。

用它来操纵它。

Take one class level static variable for querystring.
And use it for manipulating it.
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);
        }
    }





希望这个帮助

- ----------------

Pratik Bhuva



Hope This Help
------------------
Pratik Bhuva


嘿那里,



试试这个:

a 元素更改为此。

Hey there,

Try this:
change your a elements to this.
<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>



Page_Load 页面事件,添加此代码,它将添加 cat 单击第一个链接时,第二个链接的QueryString,如果尚未添加。

,我认为默认。 aspx 与链接所在的页面相同:


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:

if (Request.QueryString["cat"] != null)
                {
                    if (!aArea.HRef.Contains("cat="))
                    {
                        aArea.HRef = aArea.HRef + "&cat=" + Request.QueryString["cat"].ToString();
                    }
                }



希望这是你想要的,请告诉我它是否适合你。



Azee ......


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

Azee...


这篇关于如何使用多个查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆