MVC Validation Summary manipulation with JS and Dynamic DOM elements - model-view-controller

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

Related

dotvvm and Telerik mvc

Hi all I did search to see for answer but nothing.
My question is related to dotvvm framework.
I have installed dotvvm into a existing mvc 5 application and work correctly
but becouse the dotvvm does not know razor markup I can't use telerik ui for mvc.
Have somebody found a solution to this problem ?
Your wolkaround or council is appreciated.
Thanks
Telerik MVC controls cannot be used in DotVVM pages right now, we are thinking about MVC interop, but it's not in the framework yet.
But the MVC controls are wrappers for Telerik Kendo UI which can be used without ASP.NET MVC.
There a nice Knockout Kendo library which allows to use the Kendo UI controls with Knockout JS. Since DotVVM is based on Knockout JS, you can use the data-bind syntax in your DOTHTML pages and access the viewmodel properties:
<input data-bind="kendoNumericTextBox: Price" />
The viewmodel looks like this:
public class MyPageViewModel
{
public decimal Price { get; set; }
}
There will certainly be some limitations and unfortunately there are no DotVVM wrappers for Kendo UI, but the basic controls can work like this.
If you have more complex scenarios (DataGrid control or something like this), you can use the plain JavaScript solution and access the viewmodel properties using the following JavaScript syntax:
dotvvm.viewModels.root.viewModel.Price()
But the viewmodel is not a plain JS object, it is wrapped with Knockout observables, so you have to unwrap everything, or use dotvvm.serialization.serialize to build plain JS objects.

MyUpdatePanel.Update() in Razor

I am trying to convert my existing ASP.NET application to MVC 3 Razor. I use a lot of updatepanels, and I do conditional updates at the code behind using MyUpdatePanel.Update().
I am not finding this functionality with MVC 3. I can see a lot of blogposts talking about jQuery and how to use it to achieve the same, but I want to render other partialviews from my action conditionally. Is it possible to achieve it?
The way you'd work with Ajax in ASP.NET MVC is completely different from the ASP.NET way (i.e., Ajax toolkit with server-side controls such as UpdatePanel).
ASP.NET MVC is more basic and therefore more work. You handle Ajax calls on the client side using a library such as jQuery, and on the server side you implement a controller with Ajax methods.
Have a look at http://sweettam.blogspot.com/2011/06/aspnet-mvc-3-ajax-part-i.html.

MVC3 - Coding a custom HTML Helper which output works with unobtrusive Javascript

I am attempting to add unobtrusive JavaScript to a file upload input control, using a custom HTML Helper extension. However, I have checked various blogs which use different methods to create the control, such as tab-builder but I couldn't find out how the unobtrusive data tags are added.
Unobtrusive data tags mainly means using the HTML 5 extensible "data-" attribute.
Check this blog post of Brad Wilson about unobtrusive javascript in MVC 3, he describes the various attributes used by the unobtrusive framework.
If you are using TagBuilder, you can do this:
var validationAttributes = html.GetUnobtrusiveValidationAttributes(name, metadata);
then use MergeAttributes on your tagbuilder to add the unobtrusive validation attributes to your tag.

ASP.NET MVC3 how to switch the validation to different JS validation framework

How to switch the validation to different JS validation framework in ASP.NET MVC3? The default is Jquery validation.
Here you can find more details for what you want to do?
link text
You can also read this other question here: link text

Need to Save HTML markup from a form element

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

Resources