asp.netアプリケーションでクラスにいくつかの名前空間を含める必要があります。 using
で可能ですか?コードのないASP.NETページで 'Using'キーワードを使用する方法
私はこれ持っている:私はMVC2アーキテクチャを使用
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%
SomeNamespace.Models.NewsModel getNewsDetail = ViewData["NewsDetail"] as SomeNamespace.Models.NewsModel;
if (getNewsDetail != null) {
%>
<h2>'<%= getNewsDetail.NewsTitle%>' details</h2>
<div class="discipline-details">
<ul>
<li>
<h3> <%= getNewsDetail.NewsTitle%></h3>
<p><%= getNewsDetail.NewsDescription%></p>
</li>
</ul>
</div>
<%
} else {
%> <p class="error">No news is available. Below is listed the available news.</p>
<div id="home-news">
</div>
<%
}
%>
</asp:Content>
を...
私が直接クラスNewsModel getNewsDetail = ViewData["NewsDetail"] as NewsModel
を使用します。
ご質問ありがとうございます。ビューの上部に
(ページの最上部、ページ
Page
ディレクティブで、このコードを書きます)ビューで多くのロジックを使用するには、カスタムHTMLヘルパーを作成する必要があります。 –私はあなたの意見でReigo Hein全体のクラスに全面的に同意します... – Ruben
@Reigo:どのように独自のヘルパーを作成するには?私はTagBuilderメソッドを持つ新しいクラスを作成する必要がありますか?またはどのように? –