kenodui grid WebApi CRUD - asp.net-mvc

On the KendoUI site, I've found a working example of a KendoUI grid with MVC wrappers.
I don't use those wrappers.
Is there already support for json(p) for WebApi?
I've tried with the JsonPMediaTypeFormatter, with no decent result.
I can only read for the ApiController, but the put, post and delete don't work.
any examples?

You cannot do POST over JSONP.

Yes, there is an example on github.com site look at this :
https://github.com/telerik/kendo-examples-asp-net/
or
https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-webapi-crud
this is web api and you can download it az zip file then add web-api assembly to it, it works with web-api very nice.
you can search about what exactly you need on this :
https://github.com/telerik/kendo-examples-asp-net/commit/b6d70769fc226340e16a7fdb6da4329331f7927b

Related

Generate HTML page from Swagger documentation

I have simple ASP.Net WebApi that use Swagger, added it using Swashbuckle. I need to show Swagger documentation as a HTML page from my ASP.Net app.
I don't know where to start, any suggestion or link would be great.
Thanks!
When you activate Swagger you can see the docu online at
https://yourpath/swagger/index.html (or something like that).

Angular 4 ng-controllers

I am building an Asp.net website with Angular 4 and bootstrap. Being a .net developer, I would like to have all the html in the .cshtml files. Earlier I have used Angular 1.0 version and we use the ng-controller and all the services call will be made from there. Trying to find documentation on using controllers but couldn't find any? Do we have ng-controllers in Angular 4? If not whats the best alternative. Also I dont want to use "TemplateUrl" in the component to render the cshtml content. In few cases, cshtml will have dynamic content and don't want an additional http request made.
Thanks in advance.
Thats right what Usman told you. At Angular 2/4 your App structure is completly new. You got a Template which is controlled by the #Component, where is linked with the attribute: 'template: "Page.html"'. There is also the templateURL Which is also an attribute of #Component. Use this if you want to specify your templateURL in your Typescript File. And another thing: Your Scope has changed a bit so think about it if you try to call javascript code in your template.
hope it helped.
There is no ng-controllers in Angular 2/4. You have components (kind of, but not exactly, controllers in AngularJs). There is no clean way of using server side views with Angular 2/4 unless you want to use server side rendering of Javascript using nodejs.
Have a look at this post https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
This is based on Microsoft's JavaScript services library which does server side compilation for cshtml files. Steve Sanderson has a nice post (though a bit older now) about setting up Angular with ASP.NET
hope this helps.

How to retrieve all static texts from resource in a mvc website?

I want to build a multi language website. I found some resource about that but I don't know how I can retrieve texts from resource file and put it on a HTML tag.
for example I have a h1 tag and I want to get it's text from resource file and change this text according to selected language.
I mean I don't know about how to use localization in views.
thanks for help
As i do not have reputation to sent a comment yet. Here is a link on how this is done from Microsoft for ASP.NET Core MVC.
Globalization and localization
For ASP.NET MVC 5 you can check a helpful tutorial from CodeProject
You can read this article about ASP.NET Core MVC Localization by URL.
And also there is GitHub repo of implementation of that article. Project is built on ASP.NET Core 2.0.

Is it possible to remove all .Net MVC components in a .Net Web Api application so that I can use AngularJS as the front end?

I'm creating an application with a .Net Web Api project wanting to use pure AngularJS as the client side. Since Web Api is built on top of MVC, it creates MVC specific and default items that I feel is not needed. These items include the HomeController, _ViewStart.cshtml, _layout.cshtml, etc. I tried removing them but it comes up with errors. Has anyone tried to remove the MVC stuff out of the web api project and used separate client side front-end? Is it even possible to remove the MVC items without errors?
Remove RouteConfig.cs from App_Start, remove the Views directory and all sub-directories including the Views internal web.config file. Comment out or delete all the lines in the Global.asax.cs Application_Start method except GlobalConfiguration.Configure(WebApiConfig.Register). Remove the HomeController, add an index.html and any needed Angular scripts and go at it. I also added solution folders to organize my views as reusing the existing Views folders did not work. I'm using VS 2015 but is should work for 2013 also. PWE
Web API is not built on top of MVC.
The default templates bring in MVC for the sake of supporting a help page, but you don't need to use it.
You can start with an empty web project and just check Web API.
The routing piece is server routing and it's part of what maps the URL to Controllers+Actions, it has nothing to do with Angular routing.
As Mike Cheel alluded to, there are no dependencies between MVC and Web API. However, if you use the built-in templates, it's easy to get the impression that the 2 are linked. They include a lot of stuff in these templates because they can't anticipate where you want to go with your project... so they try to cover all the bases.
For your purposes, you would probably be better off to start with an empty project and add only the components that you actually need. For this approach, some of the best tutorials and starter projects are from Taiseer Joudeh's "Bit of Technology" blog. His tutorials helped me to build an "MVC Free" web application from scratch that uses JSON Web Tokens and AngularJS Interceptors for security and Web API 2 and Entity Framework to serve up the data.
He has many tutorials on his website... but you might want to start with "AngularJS Token Authentication using ASP.NET Web API 2, Owin, and Identity". What what.. you didn't ask about security? Well... security is an issue that you will need to confront at some point anyway... and Taiseer presents a nice solution for securing an Angular/Web API application.

Steps to be taken to implement JQgrid in MVC4 Razor,using Entity Framework

I am new to this MVC and JQuery, i started building small application using these, i am using MVC4 Razor ,with Entity Framework. i fallowed few online tutorials for the. but nothin is working out properly. i am able to get my Json data from my controller but the data is printing on my view as a java script array, jqgrid is not displaying, i guess my jqgrid itself is not called, or its not being referenced properly. please tel me what are all the things need to do, and directory structures to be fallowed.
Thanks in Advance
You can easily get jqGrid and other Grids like Telerik from Nuget Package Manager. Each of them must using their own inbuilt functions to handle the events. You will have to learn them to implement it. You can check demos from below link:
jqGid:
[link] http://www.trirand.com/blog/jqgrid/jqgrid.html
Telerik:
[link] http://demos.telerik.com/kendo-ui/?mvc
[link]http://demos.telerik.com/aspnet-ajax/

Resources