I am using .net MVC 3 razor to develop a web app and I would like to create a new page for the shopping cart only if it doesn’t already exist. I have the following code:
<p class="button">
@Html.ActionLink("Add to cart", "AddToCart",
"ShoppingCart", new { id = Model.ToyId }, new { target = "_blank" })
</p>
The above code creates a new page however it will always create a new page even if the shopping cart page has already been created.
Is there a way to check if the page already exists and move to that page or create the new page if it doesn’t exist?
You could do each of the following:
Add this information to your Model
Replace the action-link action with a simple js function that will ajax the server to check whether or not it already exists and act by it
EDIT: I think I didnt undersatnd your question – you want to open a new window only if this window is not currently open, what you shoud do is insted of _blank, place a simple string like “shopping_cart”, this will automatically reuse the window