C# PostBackURL in Code behind?

Hi All,

I’m really new to ASP.Net C# and I’ve got a problem using PostBackURL

I have a shopping cart. The cart contents is database driven. When the user wants to click continue to purchase the items in the cart, I need to pass the cartID to the next page (order.aspx). However, I also need to recalculate the cart contents to ensure no quantities have been altered.

So I really need an onclick function to call the recalcCart function and then use PostBackURL (or equivalent). I can’t seem to find a way to do it.

I don’t want to use querystring or server.transfer (want to a move to the next page)

Any help would be greatly appreciated.


PS this would have been easy in classic ASP!!! :rofl:

What if, you make of a class file and create your function in that class file. Aside from that, declare a parameter by reference of your control. And on the control’s click event, invoke the function that you made in order for you to recalculate the content of the cart.

one way of doing it would be putting them on a session variable. then you can access it from any page.

But what if the user has 2 pages open with 2 different carts? Sessions are nasty race conditions at times.

Personally, I would use a standard postback here and then just forward the user to the appropriate page assuming everything checks out.

i think create a parent class inherit with page classes. then simply recalculate and transfer link to next page

You can store them in a table and fetch in next page from DB.

you can use a query to take your variables to the next page if you don’t wanna use a session