aspxビューエンジンを使用して、次の部分ビューを作成しました
<%: Html.Telerik().DatePicker()
.Name("datePicker")
.Format(ViewData["dateFormat"].ToString())
.Value(ViewData["dateValue"].ToString())
%>
現在、私の単一ページで、この部分ビューを 2 回使用しています。メインページの内容
<%: Html.Partial("DateTimePicker") %>
Some Code and again Partial View
<%: Html.Partial("DateTimePicker") %>
名前が同じである可能性があるため、正しく機能していません。
この問題に取り組む方法は?
実際、問題はjavascriptにあります。
div class="t-widget t-datetimepicker">
<div class="t-picker-wrap">
<input id="datePicker" class="t-input" type="text" name="datePicker">
<span class="t-select">
<span class="t-icon t-icon-calendar" title="Open the calendar">Open the calendar</span>
<span class="t-icon t-icon-clock" title="Open the time view">Open the time view</span>
</span>
</div>
</div>
<div class="t-widget t-datetimepicker">
<div class="t-picker-wrap">
<input id="datePicker" class="t-input" type="text" name="datePicker">
<span class="t-select">
<span class="t-icon t-icon-calendar" title="Open the calendar">Open the calendar</span>
<span class="t-icon t-icon-clock" title="Open the time view">Open the time view</span>
</span>
</div>
</div>
それが、Firebug が表示する HTML です。ここでは、両方の入力 ID が datePicker であるため、Java スクリプト関数が機能しません。部分ビューで Id を動的に取得する方法。