dotvvm and Telerik mvc - user-interface

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.

Related

How to set popupCollision configuration property of Kendo Menu using Asp.Net Mvc HtmlHelper?

The example for Kendo Menu documentation here sets the popupCollision property in Javascript. How can this property be set using Asp.Net MVC HtmlHelpers for Kendo Menu?
According to Menu Builder ASP.NET MVC documentation there is not such property. Unfortunately this differeneces sometimes happens betveen JS and ASP versions like there are two other teams of developers.
MVC HTML Helper just generate JavaScript code, so you can try set it using JavaScript setOptions on document ready:
$("#menu").data('kendoMenu').setOptions({
popupCollision: false
});
Or even better, use the javascript version in the first place if you need this property.

Events in ASP.Net MVC

I read that there aren't events in ASP.Net MVC.
However, I added button and when I double click it a buttonClick event was made.
So, are there events in Asp.Net MVC or not?
That is because you are using the webforms view engine. This view engine includes all the page life cycle stuff from the webforms framework. That means that you can, theoretically, use anything from webforms in asp.net mvc if you are using the webforms view engine. However, I'd strongly suggest that you don't do that. You will miss out on all the advantages with asp.net mvc and you'd be better of just using webforms in the first place.
If you are new to asp.net mvc I'd suggest that you'd use another viewengine instead as that will help you learn the framework a lot better and faster. There is a viewengine from Microsoft called Razor that you could start with.
If you're seeing a buttonClick event handler created when you double-click a button, you are likely attempting to use the Button server control. Instead you should simply include an <input type="submit" value="Button Text" /> element within a <form>. The form's action will result in the controller's action method being called on the subsequent post request.
I highly suggest that you do some do some research on ASP.NET MVC. There are several good resources, but here's a short introductory video to start with:
http://www.asp.net/mvc/videos/mvc-2/how-do-i/5-minute-introduction-to-aspnet-mvc
There are not server control events like there are in webforms. There are jQuery and javascript events that can happen in the HTML/DOM though.
If you double clicked a button on a designer canvas in visual studio, and it created a button click method in another file with a signature like public void MyEvent(EventArgs e), then you are not working with an MVC project.

Validating Dynamically added controls in ASP.NET MVC

I am trying to get validation to work for my very first ASP.NET MVC application. My problem is that all my controls were dynamically created. I have a Telerik tabstrip that has tabs that were dynamically (or programmatically) added. Each tab has a partial view with controls. The model that those controls map to is an Entity Framework model. I have decorated the model properties with annotations like “[Required]” (from System.ComponentModel.DataAnnotations;) and have added controls like Html.ValidationSummary and Html.ValidationMessageFor (for each field in your model) and I've been told it's supposed to work like magic! But it doesn't :(
Any ideas why my validation is not working? Do I have to do something special because the controls were created dynamically?
Steve
P.S. BTW, the server side validation works, but not the client side.
You need to store the datatypes and override the Validate() method on the Model. And verify casting works with the stored datatypes and the values of the dynamically created controls.. if the cast doesnt work return a validationresult.

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.

MVC Validation Summary manipulation with JS and Dynamic DOM elements

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

Resources