Server side validation in Asp.net MVC4 - dynamic

I am trying to build a website using ASP.Net MVC, where in I need to dynamically display N number of controls of different kind, and validate them.
My approach is to add them to a partial view using a html helper extension which is working well. But I am clueless on how to perform server side as well as client side validation for the same.
Please help me with suggestions on this.

Related

Should I have views in a .NET Core API

At the company I work at we have a couple of different services
API (.NET Core)
Internal Frontend (React)
External Frontend for customers (React)
I was asked to create some views which will be converted to PDF's by an API, but I can't decide where to put them as they are not related to our Internal- or External-facing projects.
My first thought was to put them in our .NET Core API. However this has previously been a strict json-only API, so I have an itch that this is not the intended use.
So internet, my questions are as follows
Is it a big NO-NO to put Razor-views in our API?
Should I dedicate a microservice to this?
What is best practice?
Thanks in advance!
You're right, Razor views will be excess. I see two options:
Backend: Create an endpoint which will return a PDF file based on passed data. Of course you can expand data. This way is similar with Razor: you have a view model and render it to PDF file. An example of library: iTextSharp.LGPLv2.Core
Frontend: Convert HTML to PDF on client's side. Something like react-pdf
I prefer first option, because, first of all, there is already an option "Save as PDF" in browsers, so it will be some kind of duplication of functionality. And on the other hand back-end PDF generation seems more flexible (you can use all of your domain and you can create independent layout either) and you can organise some kind of file cache.

is an ajax call after rendering an mvc view duplication

I'm going to be developing a new system and am toying with the idea of either creating a single page application or a full asp.net mvc website.
I want to utilise knockout so if I went down the mvc route i'd need to load my mvc view and on document ready then make the ajax call to bind to my knockout view model.
Is this a bad approach as i'm effectively making 2 calls to get one page?
Depends really on your exact page design and behavior.
But generally MVC and knockout do not require you to get the data via ajax, you can populate your data from the server then manually apply bindings to your observables.
saving the data could be done via ajax.
Of course its all theory now, you need to see your screen designs and check which way to go.

MVC 4 ASP.NET 4.5 dynamic form builder options?

I have developed custom form builder type application using ASP.NET 3 years back. Now working on new project and it has similar requirement. I think there must be something new and easy to do same thing using MVC4 or ASP.NET 4.5 web forms. Any pointers?
Requirement in detail,
This is a web application
Authorised users login to web site and given the option to fill in the form
This form captures the information which then sent to third party
Third party keep reviewing their system and may ask for more details in future
My application needs modification to capture this extra(or say changing) information
Is there any way I can change only DB model to accommodate these extra fields and they will automatically appear on form without any code changes to UI or BL level?
I am not too sure what you are trying to accomplish but maybe this could help ?
http://lostechies.com/erichexter/2012/11/20/twitter-bootstrap-mvc4-the-template-nuget-package-for-asp-net-mvc4-projects/
Look at how they automatically generate the bootstrap views depending on which view model get's passed.

ASP.NET MVC 4 Loading lookup data

I was wondering how dropdownlists shoud be loaded ? How people do that usually ? The data in my dropdown are quite disconnected from my Model so they should not come from the Model.
Should I use the new MVC web api services to return the required data ?
Please refer to this tutorial ,it describes basic way to use dropdown list in asp.net mvc and its quite simple also

Real time data from VB.net app to web server

I'm fairly new to VB.net programming. I'd like some suggestions for methods/procedures for sending real time data from a VB.net app to a web server (asp.net) for real time display. My question relates to the best method to send the data from the desktop app and the best way to receive and handle the data on the server. I'm not asking for sample code, just some idea of what methods to research. I am currently using a text file upload method but I'm sure there is a more efficient way of achieving this. Thanks in advance for your help.
For sending data to the server, you may research about webservice or WCF.
http://en.wikipedia.org/wiki/Web_service
http://msdn.microsoft.com/en-us/netframework/dd939784
For retrieving data from the server to your ASP.Net application, you can research about AJAX.
http://www.w3schools.com/ajax/default.asp
http://api.jquery.com/jQuery.ajax/
If you are using the MVC framework for ASP.NET (which I strongly recommend over WebForms), MVC4 which has recently gone into RC mode features a very nice new web API:
http://www.asp.net/web-api
"ASP.NET MVC 4 includes ASP.NET Web API, a new framework for creating HTTP services that can reach a broad range of clients including browsers and mobile devices. ASP.NET Web API is also an ideal platform for building RESTful services."
It allows you to define quite simple methods on the server which work directly with your actual domain objects and it does the work of returning data in an appropriate content type (e.g. JSON, XML) based either on the incoming request or a specific configuration you may set.
Your web app could then poll the GET methods on the same API controller class via Ajax (jQuery is nice) to display the results.