UIHint data annotations slow down the rendering process - asp.net-mvc

An MVC 2 C# .NET 4.0 project with Entity Framework contains a view with a user control displaying a Telerik MVC Extensions grid. The grid uses one table with many fields and displays correctly.
When editing the grid rows, many of the fields need to be drop-down lists. To create them, I need to annotate the fields in my table with uihint; this uses a editor template that is my drop down list.
There are 13 data annotations for fields for the table object. Due to these annotations, the grid renders very slowly. What can be done to optimize this?

Related

Umbraco, how to add onChange functionality on dropdown content backoffice?

I am having one document type which contains a dropdown list, I need to add a couple of things in it:
I need to display the Database table names in drop-down dynamically.
On the change of dropdown option, i need to display the selected table columns names in another drop-down.
Are above things possible by using only existing data types or it will require creating a custom template using razor syntaxes (if it is so then how the template will display directly in the back office content node?)
Can you please provide your views and any links for code/tutorials?
screen shot of content form
If this is for the back office, you will need to do it in HTML and Angular, with an API controller to handle the DB lookup stuff.
As far as I'm aware, there's nothing built in to do dropdowns that depend on each other, so you'd have to create a new DataType to do it.
The process is to long to detail here, but here are some useful links on creating custom DocTypes in Umbraco 7.
https://our.umbraco.org/documentation/tutorials/Creating-a-Property-Editor/
http://velstand.info/tips/umbraco/to-create-a-datatype-by-using-external-data-sources/
https://24days.in/umbraco-cms/2016/custom-property-editor-tutorial/

Create a View of type List in ASP.NET MVC 2

I am practicing MVC 2 (I'll do MVC 4 in just a bit) after almost 2 years, just to revise before I jump to MVC 4.
I am creating a strongly typed view of one of my data objects called Category. I want to create a list type view, i.e. a view that displays all records from the Category table.
I recall there used to be T4 templates of each type of view -- Index, List, Create, etc. that you could choose from.
But I can't find them. When I create the View, the Add View dialog shows a disabled input field for View content.
I don't think you can have Visual Studio generate the list for you. After all, you need some lookup logic to get all the objects you want to display in the list.
You might want to check out this blog post for a nice way to pass a list of objects into your drop down list. You will, however, need to supply the objects yourself.

Razor view display domain model properties without knowing the domain model

Background: I have a simple mapping app (backed by GeoServer) that allow a user to click on a feature and select a data table displaying information about the selected feature. A HTML table would then be inserted under the map to show the query results.
Problem: Since there are at least 40 something tables that the user can select, I don't want to build 40+ partial views. Is it possible to build a Razor view that can handle any model passed to it and build a HTML table without knowing the domain model's structure? I'm leaning toward no after some poking around.
Reference: Related to my previous question of
Dynamic DBSet lookup and query
Practically, asp.net mvc already does that when you call EditorForModel, DisplayForModel or similar. If there is no developer defined view for corresponding model type, it calls object template, which uses reflection to render editor and display views. That template does not have predefined knowledge of model type.
You could set model type to object for view, and make use of reflection to generate tables.

MVC selectable GridView

I am designing a webpage using MVC. One of the pages has the following controls and functions:
Controls:
2 GridViews (gvItems, gvSelectedItems)
3 buttons (btnTransferSingle, btnTransferAll, submit)
Functions
gvItems will be populated with a set of items that contains: Name, points
gvSelectedItems will contain items that is transferred from gvItems. Hence it will also contain: Name, points
both GirdViews supports multiple selection
btnTransferSingle will transfer all selected items from gvItems to gvSelectedItems.
btnTransferAll will transfer all remaining items from gvItems to gvSelectedItems.
btnSubmit will send all the items from gvSelectedItems to the Controller.
I am not sure how to the following:
1) How to create a gridview that supports multiselection and displaying of multiple model attribute.
2) How to transfer the items from one gridview (gvItems) to another (gvSelectedItems)?
3) How to pass back all the items from gvSelectedItems to the controller?
I am able to do the stuff that was mentioned using listBox but listBox only allows displaying of only one attribute and doesn't have a header.
I used Matt Kruse Javascript's Toolbox to aid the moving of items between listboxes.
Any help is appreciated. Thanks.
I think that listboxes are the correct approach here.
If you want to display both attributes try to concatenate them when loading the data.
Headers can be somewhat added with html/css

How do I preserve Telerik MVC grid column order and sizes when paging?

I have a Telerik ASP.NET MVC grid that uses server data binding and has column resizing and reordering enabled. If I manually re-order or re-size the columns and then use the grid pager to jump to another page of the grid, the column sizes and order revert back to the default settings. What is the best way to preserve user changes to the column size and order when paging?
On the Telerik demos site I found an example that uses hidden form fields with AJAX data binding, but as far as I know that won't work for the server binding HTTP GETs. I started down the path of using cookies instead of hidden form fields, but it started getting messy and I was looking for feedback on alternative approaches.
You could pass the column widths down to the grid either as part of your model or with ViewBag (or ViewData if you're using MVC 2)
You can then set your column widths using:
.Width((int)ViewBag.col1Width);
- or -
.Width((int)model.col1Width);
You can then update the values using a callback via the OnColumnResize event (this is raised when a grid column is resized by the user)
If you're using session state, you could also store the values in session variables if they are to persist throughout the user's session.

Resources