0

我正在开发一个使用 Asp.net 3.0 开发的零售网站。我有一个购物车系统,所以当用户将一些商品添加到他们的购物车时,他们会被重定向到购物篮页面。我在篮子页面上有一个按钮,让他们返回添加更多项目。我不知道该怎么做。

情况就是这样。

Home Page -> Mens Clothing Product List -> Jeans Page -> Basket pgae

现在,当用户访问男装时,他们会看到所有商品,然后他们会选择一件他们想购买的牛仔裤,然后他们会被重定向到牛仔裤页面。现在他们将商品添加到他们的购物篮并重定向到购物篮页面,现在我在购物篮页面上有一个名为“继续购物”的按钮,当他们点击时(截至目前,他们被重定向到主页)但我需要他们重定向到男装产品列表而不是主页。

CASE 1

我用谷歌搜索了它,发现我们可以使用 URLReferrer 并检查它是否为空。但在我的情况下,它始终是篮子页面 URL,因为我在牛仔裤页面上使用 Response.Redirect。所以我不能使用 URLReferrer。

CASE 2

我还发现使用 Javascript History 我们可以回到 1 或 2 页。但是因为我想保留用户数据和 CART 我也不能使用它,因为它会使用浏览器缓存并且不会保存任何用户数据。

CASE 3

我正在考虑使用上下文或会话将当前页面 URL 存储在牛仔裤页面上,我可以在篮子页面中检查它,如果它不为空,则重定向到该页面。但我想再退一步,即。男装页面不是牛仔裤页面。

我真的不确定这是否是一个好主意。请建议。

谢谢...

4

4 回答 4

2

使用Response.Redirect转到所需的页面并使用会话存储 Basketdata。

对于重定向使用:

protected void btn_click(object sender, EventArgs e)
{
    Response.Redirect("desired page.aspx");
}

用于存储使用数据集或数据表并将其存储在会话中。

    Session["items"] = ur_DataTable as DataTable;

     or

     Session["items"] = ur_DataSet as DataSet;

ur_Datatable 或 ur_DataSet 将包含您添加的产品。

于 2013-01-31T10:21:51.237 回答
2

要渲染另一个页面并保存其数据以在当前页面中访问,请执行以下操作

protected void button_Click(Object sender,EventArgs e )
{
   session["give your prefered Name to session"]=your value.its whatever
   response.redirect("your Page URL to Redirect from this page to that page");
}

现在访问您在另一个页面上的会话中存储的值。执行以下操作,会话返回的默认值是“对象”类型,因此您可以使用显式转换转换为任何数据类型

在这里,我将对象值转换为字符串,

protected void Page_Load(object sender, EventArgs e)
{
    string value=session["Use Same Name as u have given to it"].ToString();
}
于 2013-01-31T10:46:04.390 回答
0

在 asp.net 中进行简单状态管理的一种方法是使用隐藏字段。使用隐藏字段存储位置并将位置传递到购物篮页面。

于 2013-01-31T10:26:03.827 回答
0

Now when users go to "Mens Clothing" they see all the items, then they select one "Jeans" they want to buy and they are redirected to "Jeans" Page. Now they add items to their basket and they are redirected to "Basket" Page.

Now I have a button on "Basket" page called "Keep Shopping". When they click I need to redirect them to Mens Clothing Product List instead of Home Page.

Now you say you want to redirect to the "Mens Clothing" page, but you have to determine why you want to redirect to that page. If it always is that page, then hardcode that:

Response.Redirect("Shop/Categories/Mens-Clothing");

Though when the page you want to return to depends on what item was added to the basket, you need to realize what page you want to redirect to and how the relation of that page is with regard to the item.

The Basket page knows what item is being added to the basket. If you for example want to redirect to the category page for that item, look up the category this item is in, and redirect to that page:

Response.Redirect("Shop/Categories/" + item.Category.Name);

Although this will redirect you to the "Jeans" page, because that is the choosen item's category.

Now it looks like you want to redirect to the parent category of the category the item is in. Then you user that:

Response.Redirect("Shop/Categories/" + item.Category.ParentCategory.Name);

Or whatever your data model looks like.

于 2013-01-31T10:30:13.917 回答