【发布时间】:2017-12-11 19:15:57
【问题描述】:
我正在用 MVC 开发一个 Web 应用程序。 我在数据库中添加了一个链接例如:“www.google.com”,我希望用户在点击时重定向到 Google。
我尝试了很多方法,但将控制器放在地址栏中 "eg:http://localhost:/Home/www.google.com"
查看代码
<table class="table" style="margin-top:10px;">
<tr>
<th>
Sr. No.
</th>
<th>
Name
</th>
<th>
Details
</th>
<th>
Status
</th>
<th>
Tracking No.
</th>
<th>
Tack Order
</th>
<th>
Ordered On
</th>
</tr>
@{int row = 0;} @foreach (var item in Model) { if (item.PaymentSuccessfull == true) {
<tr>
<td>
@(row += 1)
</td>
<td>
@Html.DisplayFor(modelItem => item.DeliveryDetail.FirstName)
</td>
<td>
<a href="/Home/OrderDetails?orderId=@item.Id" orderid="1">Order Details</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
@Html.DisplayFor(modelItem => item.TrackingId)
</td>
<td>
//Here I want user to redirect to Google on click
<a href="@Html.DisplayFor(modelItem => item.TrackingURL)" target="_blank">Track</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.DateTime)
</td>
</tr>
} }
感谢您的帮助。 提前致谢。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-3 model-view-controller hyperlink