Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, I have a MVC application and I am using a rich text box control in a textarea control. I have bind the page with the Model and fetching the data from the class properties. here is the textarea control to use the Text Editor

<textarea class="rchTxtAr limit-max-char-500" name="txtAddArActResponsibilty" id="txtAddArActResponsibilty"
                    rows="10" cols="90"></textarea


I am serializing the form and then post the form to save the data

var data = $("#myform").serialize();

$jUnt.ajax({
           url: "/mycontroller/SaveData",
            method: 'post',
	    type: 'html',
            data:data,
	    success: function (data) {}
            }); 


When I do this it's show the following error

A potentially dangerous Request.Form value was detected from the client in...


I have also set the [ValidateInput(false)] property in the SaveData action..Would you please let me know how to solve this problem?
Posted
Updated 7-Feb-11 23:18pm
v2
Comments
Richard MacCutchan 8-Feb-11 5:18am    
Corrected formatting.

 
Share this answer
 
Hi
following code worked for me even without [ValidateInput(false)]

/*------------------------------View---------------------------------*/
XML
<script src="../../Scripts/jquery-1.4.4.js" type="text/javascript"></script>

    <script>

        function onSubmit() {

            debugger;

            var data = $("#myform").serialize();



            $.ajax({

                type: "POST",

                url: "http://localhost:49941/Home/SaveData",

                data: "data=" + data,

                success: function (msg) {

                    alert("Data Saved: " + msg);

                }

            });

        }

    </script>

    <form action="SaveData.aspx" method="get" id="myform" onsubmit="return false">

    <textarea name="txtAddArActResponsibilty" id="txtAddArActResponsibilty" rows="10">

        cols="90"&gt;</textarea>

    <button value="Submit Data" type="button" onclick="javascript:onSubmit()">

        Submit Data

    </button>

    </form>


/*------------------------------Controller--------------------------------*/
[AcceptVerbs(HttpVerbs.Get)]

        public ActionResult SaveData()

        {

            return View();

        }



        [AcceptVerbs(HttpVerbs.Post)]

        public ActionResult SaveData(string data)

        {

            return View();

        }





$("#myform").serialize(); code will encode all our data so no need to write [ValidateInput(false)]

please modify your code according to the above code
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900