I want to save html markup in my database for a field from an ASP.Net MVC2 application. Upon reading I found that using the [ValidateInput(false)] attribute lets you do that. But it is not working for me. The data comes from the extjs htmleditor form element.
Anyone has any ideas? Is there something else I need to do? Any setting in web.config?
see ASP.NET Request Validation Exception Even When Validation Is Disabled
Related
I am fairly new to .NET and MVC3 - and even Ajax and Json, and am working on an MVC3 (razor) application, using jqGrid, and so far it is immense(jqgrid that is!) and has dealt with everything I have thrown at it.
However, I have One Outstanding peice of functionality that I do not know How to accomplish.
Within the Edit form of a Row, I have Placed a Custom button called 'Reset Password'. I need the Onclick Event to call a piece of functionality in my Controller to go through some logic, generate a Password, and Return the new Password to the Screen.
Can anyone tell me How can I achieve this?
May thanks in Advance.
You can return a partial view result or json data from the action.
See the partial view approach here
I have a strange scenario :
I am using asp.net mvc and I have a form which has a combination of HTML input fields and Telerik RadEditor.
When validation fails on my form I have history.back to get the user back to the form. If RadEditor has some text and if validation fails then I am losing all the data in the fields that are right below the RadEditor control. Any idea what's going on?
IS the problem reproducible without RadEditor on the page?
Have you tried to set the ContentAreaMode property of RadEditor to DIV and test?
I'm creating a site where I don't want anything to be done via custom javascript/jquery code at all, and I'm not sure it's going to be possible so need some advice.
The things that I want to be able to do are:
Load a JQuery (or Jquery style) dialog box containing a partial view.
Have a button that will select the "SelectedValue" from a dropdown list and render a partial view. (e.g. select a user from a dropdown and then click a button to add them to a list)
Append a partial view to an existing div.
I'm sure that all the above can be done using custom javascript, but what I want to is to use the standard Ajax and Html helpers that come with MVC3.
Main reason is that I've been struggling to get to grips with jQuery, but I also thought it would be nice to see if it can all be done without having to add a new script to the site.
As always, any help is greatly appreciated (even if it's just pointing me to articles).
The standard Ajax and Html helpers that come with MVC3 are for handling server-side stuff. Even the #Html.ValidationMessageFor helper usually uses their unobtrusive validation lib for jQuery validate.
Keep trying at jQuery, you'll get it. There is a reason it is so popular!
Update
I believe you can do #3 using #Ajax.ActionLink, but don't think you can do 1 or 2 out of the box with the Ajax html helper.
It seems that you can use the Ajax.BeginForm method to do this.
There are issues with the fact that it has been in a separate form as I can't nest the forms though.
I am adding fields after the page load and would like to know how I can interface my JS with .net's validation summary on MVC.
Does a simple way exist?
Thx!
The easiest method is to use jQuery and get the validation summary.
var ul = $("#validationSummary ul");
ul.append("<li>Custom Error Message</li>")
as is done here: link text
You can use asp.net MVC with its server side and client side validations.
Basically you need to apply rules for validation while defining a models (Class Files)
Following is link which will describe Model Validation in ASP.NET MVC.
Model Validation in ASP.NET MVC
I've encountered a pretty weird situation, I'm using Win7, VS2010, ASP.NET MVC2, jQuery. I have a simple form a textarea and a button doing a .post() ajax call to server, pretty simple setup.
It works when I input plain text in the textarea, but if I mix html tags like bold, then it works sometimes!!
I do have [ValidateInput(false)] on the action method and ValidateRequest="false" on my view, the things is that what I have does work, sometimes.
So when I debug it and mix html tag and submit, it does go into the the action method correctly, sometimes. While other times, like when not in debug, it just does not stop in the action method at all.
Very Werid! Just thought to ask if anyone else had this problem before?
It turns out that make this to work I need to have the following 3 things on my ASP.NET MVC app ready,
ValidateRequest="false" on the view
[ValidateInput(false)] on the action method
<httpRuntime requestValidationMode="2.0"/> on the web.config
The last thing is what I missed, I found this out by using FireBug which returned the entire asp.net Yellow Screen in html in its console.
Interesting thing is that without the last item, when you input html tags in the textarea the app should NOT work but throw some security exception, but it worked when I debugged my app which made the whole thing confusing.