How do I use ACE with my ASP.NET MVC application?

前端 未结 3 1911
孤城傲影
孤城傲影 2021-02-14 03:32

I want to use the ACE online code editor in my project. How do I use it in ASP.NET MVC?

I\'d like to save whatever edits are made with that editor in the database. How d

3条回答
  •  独厮守ぢ
    2021-02-14 04:02

    Let's assume you have a strong typed model with a property called Editor with the data in it. Now use a normal

    to load the data:

    <%=Model.Editor %>

    Now you can create an ace editor in place of the div with javascript:

    
    
    

    Now when you want to save the data, for instance via a form post, use something like this to bind it back to the Editor property of the model:

    <%=Html.HiddenFor(m=>m.Editor, new { @id = "hidden_editor" }) %>
    
    
    
    

    In your controller you can now save the data to the database

    [HttpPost]
    public ActionResult Index (IndexModel model) {
        var data = model.Editor;
        // save data in database
    }
    

提交回复
热议问题