将一个查询字符串连接到另一个查询字符串而不更改其他字符串 [英] concatenate one querystring with another without changing of other

查看:65
本文介绍了将一个查询字符串连接到另一个查询字符串而不更改其他字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处于这样一种情况:用户可以选择类别或区域..用户也可以同时选择..



i使用查询字符串进行数据操作..例如。 default.aspx?cat = shoes default.aspx?cat = shoes& area = California



我的问题是,如果用户首先选择类别,那么当用户选择区域时,类别应该保持不变,区域应该与类别连接..如果用户选择区域第一区域应该保留未触动过..



希望你理解我的问题......如果没有,真的很抱歉。

i am in a situation where user can select either category or area.. user can also select both..

i am using query string for data manipulation.. eg. default.aspx?cat=shoes or default.aspx?cat= shoes&area=California

my question is if user selects category first, after that when user selects area then category should be remain untouched and area should be concatenated with category.. same if user select area first area should remain untouched..

Hope u understand my question... really sorry if not.

推荐答案

已经回答:



如何使用多个查询字符串 [ ^ ]



Azee ...
Already answered:

how to play with multiple query strings[^]

Azee...


你应该试试java希望你的问题能解决的脚本。我已经提供样品请根据您的要求检查和修改

javascript代码如下:



you should try java script for that hope your problem will resolve. i have give a sample please check and modify as per your requirement
the javascript code is as :

<script type="text/javascript">
       function openWindowForNavigation() {
           // getting the current url with query string
           var query = document.location.href;
           window.open(query +'&cat='+50);
       }
   </script>





和您的超链接是



< asp:hyperlink id =HyperLink1runat =servernavigateurl =javascript:openWindowForNavigation(); xmlns:asp =#unknown> HyperLink



and your hyperlink is

<asp:hyperlink id="HyperLink1" runat="server" navigateurl="javascript:openWindowForNavigation();" xmlns:asp="#unknown">HyperLink


为查询字符串选择一个类级别静态变量

并将其用于操作它。

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


这篇关于将一个查询字符串连接到另一个查询字符串而不更改其他字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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