您好,我正在尝试根据 MVC 音乐商店教程在我的 MVC 电子商务网站上使用贝宝按钮。我正在从数据库中加载特定数据,因此我希望在我的网站中为每个类别提供一个带有下拉菜单的按钮。我想知道如何在教科书类别启动时隐藏一个按钮,并在固定类别启动时再次显示它,因此我只有在任何时候都可以看到该类别的特定按钮。所以基本上当视图指向浏览教科书类别时,我只希望教科书按钮可见。我的代码如下
存储控制器:
public ActionResult Browse(string category)
{
// Retrieve Category and its Associated Products from database
var categoryModel = storeDB.Categories.Include("Products")
.Single(c => c.Name == category);
return View(categoryModel);
}
浏览视图:
@model WholeschoolStore3.Models.Category
@{
ViewBag.Title = "Browse Categorys";
}
<div class="product">
<h3><em>@Model.Name</em> Products</h3>
<ul id="Product-list">
@foreach (var product in Model.Products)
{
<li>
<a href="@Url.Action("Details", new { id = product.ProductId })">
<img alt="@product.ProductName" src="@product.ProductUrl" />
<span>@product.ProductName</span>
</a>
</li>
}
</ul>
<form target="paypal" action="" method="post">
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="hidden" name="hosted_button_id" value=""/>
School Books<select name="os0">
<option value="History Book">History Book €38.99 EUR</option>
<option value="Biology Book">Biology Book €34.99 EUR</option>
<option value="Math Book">Math Book €39.99 EUR</option>
<option value="Geography Book">Geography Book €34.99 EUR</option>
<option value="Business Studies Book">Business Studies Book €37.99 EUR</option>
</select>
<input type="hidden" name="currency_code" value="EUR"/>
<input type="image" src=""
width="1" height="1"/>
<img alt="" border="0" src=""
width="1" height="1"/>
</form>
<form target="paypal" action="" method="post">
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="hidden" name="hosted_button_id" value=""/>
<input type="hidden" name="on0" value="Stationary"/>Stationary<select name="os0">
<option value="Pencil">Pencil €0.49 EUR</option>
<option value="Pen">Pen €0.89 EUR</option>
<option value="A4 Refill pad">A4 Refill pad €3.99 EUR</option>
</select>
<input type="hidden" name="currency_code" value="EUR"/>
<input type="image" src=""
border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"/>
<img alt="" border="0" src=""
width="1" height="1"/>
</form>
</div>
我尝试了许多帖子,但没有找到我要找的东西
任何帮助将不胜感激提前谢谢