我剛開始使用asp.net的MVC .. 因爲我不熟悉它,我只想問一個關於ActionLink的HTML輔助的問題..html.actionlink
我有這樣的代碼在我的Index.aspx主視圖..
<% Dim _news As datatable = ViewData.Model%>
<% For count As Integer = 0 To _news.Rows.Count - 1%>
<% Dim id As Integer = _news.Rows(count).Item("IDnews")%>
<%=_news.Rows(count).Item("newsTitle")%>
<p>
<%=_news.Rows(count).Item("newsContent")%><br />
<%=Html.ActionLink("Read More..", "NewsPublic", "Administration", New With {id})%>
</p>
<%Next%>
如果我點擊ActionLink的,我期待它會令我這個網址: /行政/ NewsPublic/7 而是它給了我這個網址: /首頁/新聞公共?長度= 14
actionlink只傳遞id在同一個控制器中?
謝謝你提前!
感謝您的答覆.. 嗯,它給了我這個錯誤: 字段或屬性的名稱是在對象初始值設定項中初始化必須以'。'開頭。 我試過了。在「身份證」,但它說標識符的預期.. – tiff 2009-09-14 04:27:28
是啊對不起... VB初始化器比C#更復雜,我可能沒有把它正確。嘗試「使用{.id = id}新建」。 – womp 2009-09-14 04:51:26
你編輯過的一個工作!=) 謝謝! – tiff 2009-09-14 04:58:47