我有一个产品详情页面。所有产品均根据3个标准显示:
由于用户点击以下列表,这是考试网址:
问题:当用户点击下面的每个链接时,页面将刷新,因此我无法将参数字符串混合在一起。我想将这3个标准组合在一起,意味着当用户点击(1)然后继续(2)和(3)时,网址将:
http://mysite.com/Products?dep=1&cat=2&brand=ABC_2&search=ABCD&tab=2
因此页面将显示depID = 1,categoryID = 2,品牌ID = 2,品牌名称= ABC,产品名称=“ABCD”的产品。
这是我试图在我的site.master中获取(3):
function SearchClick() {
window.location = "/Products?tab=2" + ($("#txtsearch").val() != "" || $("#txtsearch").val()
== "undefined" ? "&search=" + $("#txtsearch").val() : "");
}
先谢谢。
答案 0 :(得分:1)
我注意到你正在使用jQuery,我会建议:
//using Request.Params
string Dept = Request.Params["dep"];
string Cat = Request.Params["cat"];
string Brand = Request.Params["brand"];
//capture the char after '?' or '&' and pass into Params["char"]
//do your search function.
This链接可以帮助您。
如果您想在页面刷新后保留它,可以将其存储在Session
。
string theDept = Request.Params["dep"];
Session["dep"] = aa;
string dep = (string)Session["dep"];
答案 1 :(得分:1)
这应该让你入门
后端:
前端:
使用id / name ='brand'
使用jquery,在用户点击左栏时更新隐藏字段
答案 2 :(得分:1)
如果您使用ajax加载页面,也可以尝试此操作。
$.ajax({
url: '/Products',
type: 'GET',
dataType: 'json',
cache: false,
async: false,
data: { dep: 1, brand: abc_2, search:abcd, tab:2 },
success: function (data) {
//Do your work here
},
error: function (ex) {
alert('Error.');
}
});
您通常会将3个条件放在同一页面中,例如搜索文本框,品牌/部门下拉列表,然后点按一下按钮就会触发此查询。