2011-02-28 5 views
0

は私がmvcページでDateTime.ascx(Nerdinner Editor Templates)を設定する方法は?

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime>" %> 
    <%= Html.TextBox("", String.Format("{0:yyyy-MM-dd HH:mm}",Model)) %> 
     <script type="text/javascript"> 
      $(function() { 
       $('#EventDate').datetime({ 
        userLang: 'en', 
        americanMode: true 
       }); 
      }); 
      </script> 

\共有\ EditorTemplates \ DateTimeのDatetime.ascx

\ビューを追加し、私は私のDateFromでそれを使用する必要がある - Texboxへ。

<%@ Register src="../Shared/EditorTemplates/DateTime.ascx" tagname="DateTime" tagprefix="uc1" %> 
<p> 
     Please enter your Date Range Below. 
    </p> 
      <p> 
    Please enter your Date Range Below. 
</p> 
    <form method="post" action="<%= Html.AttributeEncode(Url.Action("List")) %>"> 
    <div> 
     <table cellpadding="2" cellspacing="0" class="vertical"> 
      <tr> 
       <th>Date From:</th> 
       <td><%= Html.TextBox("datefrom") %></td> 
      </tr> 
      <tr> 
       <th>Date To:</th> 
       <td><%= Html.TextBox("dateto")%></td> 
      </tr> 

      <tr> 
       <th></th> 
       <td><input type="submit" value="Show My Orders" /></td> 
      </tr> 
     </table> 
    </div> 
</form> 

私はNerdinner

からDatetime.ascxを得たあなたはところで代わりHtml.TextBox

Html.EditorForを使用する必要がよろしく

+0

ユーザーコントロールの代わりにHTMLヘルパーを使用してみましたかhttp://を参照してくださいwww.asp.net/mvc/tutorials/creating-custom-html-helpers-cs – Daveo

+0

リンクゴンゴンの正解に加えて、JavaScriptはあなたが意図したことをするつもりですか? –

+0

NerdinnerからDatetime.ascxを取得しました – Crimsonland

答えて

1

におかげで、あなたも<%の@レジスタを使用することができます..%> MVCの構文ですか?私はASP.NET WebFormsでしか使用していませんが(ASCXは錆びているので、私はRazorを使用しています)

関連する問題