0

メモで満たされたグリッドがあり、新しいメモを追加できるようにしたいと考えています。これは 2 つの異なるビューを使用して機能しますが、CreateNote ビューで新しいウィンドウが開きます。これを同じウィンドウで開きたい。したがって、View の代わりに PartialView を使用します。これは機能しますが、「@using (UI.koform(Model, null))」が html として表示されるため、knockoutjs が機能しません。部分ビューでこれを機能させるにはどうすればよいですか?

コード:

景色:

[...]
<script type="text/javascript">
    (function() {
        $('#load-partial').click(function() {
            $('#partial').load('@Url.Action("CreateNote", "Entity", new {modelEntity = @Model.meta.entity})');
        });
    })();   
</script>

<div id="partial"></div>
<button type="button" id="load-partial">Create Note</button>

アクション:

public ActionResult CreateNote(
        [ModelBinder(typeof(Models.JsonModelBinder))]
        NoteModel Model, string cmd, string modelEntity)
    {  
        [...]
        return PartialView("CreateNotePartial",Model);

        }

部分ビュー:

<%@ Control Language="C#" Inherits="test.Web.Framework.Core.ViewUserControl<test.Web.Framework.Areas.Administration.Models.NoteModel>" %>
@using (UI.koform(Model, null))
{
<div class="ui-state-highlight ui-corner-all highlight" data-bind="visible: meta.message">
    <span class="ui-icon ui-icon-info"></span><strong data-bind="text: meta.message">
    </strong>
</div>

Subject:
<input type="text" data-bind="value:subject" />
<span data-bind="text: subject"></span>
<br />
Text:
<input type="text" data-bind="value:text" />
<br />

<a href="#" data-bind="click:function(){setvalues() }">set values</a>


<div class="dialogButtons">
    <button onclick="$('#@Model.meta.modelname').koform('submit');">
        Save</button>
</div>
}
4

1 に答える 1

2

View エンジンを混在させているようです。コントロール定義は ASPX ビュー エンジン構文 ( <%@ %>) を使用していますが、usingステートメントは Razor を使用しています。私の推測では、コードを次のように変更するとうまくいくと思います:

<% using (UI.koform(Model, null))
{ %>

<%--  HTML  --%>

<% } %>
于 2011-12-29T14:19:00.680 に答える