我有如下其定義一個劍道編輯:保存文本從劍道編輯數據庫
@(Html.Kendo().Editor()
.Name("myEditor")
.Tag("div")
.Tools(tools => tools
.Clear()
.Bold()
.Italic()
.Underline()
.Strikethrough()
.JustifyCenter().JustifyFull().JustifyLeft().JustifyRight()
.CreateLink().Unlink().TableEditing().FontColor().BackColor())
.Value(@<text>
Hello Kendo Editor <some text with html tags here>
</text>)
)
然後,我有兩個按鈕,顯示只爲管理員 - 保存和編輯,他們被定義爲下面 -
<button type="button" id="btnedit">Edit</button>
<input type="submit" name="btnSave" id="btnSave" value="Save" class="btn btn-default" />
還有其他兩種形式提交按鈕如下圖所示 -
<input type="submit" name="btnAgree" id="btnAgree" value="Agree" class="btn btn-primary" />
<input type="submit" name="btnDisagree" id="btnDisagree" value="Disagree" class="btn btn-default" />
而且FO RM處理提交的同意並通過BeginForm不同意按鈕(「ActionMethod」,「控制器」,FormMethod.Post)像下面 -
@using (Html.BeginForm("Index", "MyControllerName", FormMethod.Post))
現在我想的是,當一個管理員用戶進來,使得變化到編輯器文本並點擊'保存'按鈕,我希望編輯器的文本保存在數據庫中。我可以處理保存部分。我只想知道,我如何從Kendo Editor獲取文本並將文本值發送到控制器中的操作方法。
我想在這個線程這裏提供的解決方案 - http://www.telerik.com/forums/save-changes-to-and-print-content-of-editor-in-mvc
因此,使用該解決方案在這裏我添加了一個操作方法類似的編輯器名稱,如下面的字符串參數名稱 -
public ActionResult Save(string myEditor) {
// TO DO: Save the text to the database
}
當我運行我的應用程序,並點擊「保存」按鈕,我得到下面的錯誤 -
HTTP Error 404.0 - Invalid navigation The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
它不打「保存」操作方法。我如何得到這個工作?
感謝
謝謝@Sandman的回答。我嘗試了上面的方法,但是當它試圖從Kendo Editor獲取值時,我收到了Javascript錯誤。 0x800a138f - JavaScript運行時錯誤:無法獲取未定義或空引用的屬性「值」 – Kristy
確保您正在訪問[現有實例](http://docs.telerik.com/aspnet-mvc/helpers/editor/overview#existing -instances)在你的MVC聲明之後。 – Sandman