0

I try to assign javascript variable contentArea to content.Contents in my controller. How can I do that?

<script language="javascript" type="text/javascript">

        $("#btnTest").click(function () {
            var contentArea = tinyMCE.get("modalTextarea").getContent();

        });

</script>

Action:

    [HttpPost]
    public ActionResult Index(string test)
    {

        DBEntities dbTest = new DBEntities();

        tbl_Contents content = new tbl_Contents();

        content.RegisterDate = DateTime.Now;
        content.Title = "test";

        content.Contents = "content1";

        content.ImagePath = "image0";

        dbTest.AddToICE_tbl_Contents(content);
        dbTest.SaveChanges();
        return View();

    }

1 Answer 1

1

You need to send an AJAX request to the action's URL containing the data:

$.post("@Url.Action("Index")", { test: contentArea });
Sign up to request clarification or add additional context in comments.

1 Comment

It still Null in my database. Data type of test parameter is string and contentArea is ntext. content.Contents = test; is it possible?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.