我有強類型視圖,我想創建引用模型的鏈接,該模型與該視圖是強類型的,某些屬性(例如Model.property)。 我該怎麼做? 我使用net4.0。 當我寫「>它什麼都不做」。 即使我的視覺工作室沒有識別它,但我點擊ctrl + space就不會帶來任何東西。 這是我的看法如何在asp.net mvc中創建指向某個model.property的鏈接?
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<UrlParser.Models.Parse>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Show</title>
</head>
<body>
<h1> Title: </h1>
<%: Model.title %>
<br />
<h1> Description: </h1>
<%: Model.description %>
<% if(!Model.video.Equals("")) { %>
<h2> Video:</h2>
<%: Model.video %>
<a href="<%: Model.video %>"> </a>
<% } %>
</body>
</html>
我希望我的鏈接是指Model.video。
這些是我CONTROLER:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UrlParser.Models;
namespace UrlParser.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(GetUrl getUrl)
{
// int i = 0;
Parse prs = new Parse(getUrl.url);
return View("Show", prs);
}
}
}
我假設你想在鏈接中使用模型屬性。按照這個[鏈接](http://stackoverflow.com/questions/200476/html-actionlink-method) –
您的看法應該期待某種模式。您應該可以訪問該模型的屬性。我想你可能不得不爲我們發佈一些代碼,看看你有什麼問題。 – Odnxe
@Odnxe:我編輯我的問題<請看。 –