MVC 5 Ajax partialView loads in a new page

I had a partialView that submits to the server and then should update the PartailView. It was successfully posting to the server side code, but when the code would return the PartialView, it would display text in a new page rather than putting it back into the old page. This occurred previously when I was trying to return a Javascript result.

 

http://dyball.wordpress.com/2014/04/07/partial-view-using-unobtrusive-ajax-in-mvc-5-loads-into-a-new-page/ saved me. Basically I didn’t have the unobtrusive ajax javascript installed.

I used Nuget to install Microsoft.jQuery.Unobtrusive.Ajax, and that fixed it. I just needed to add a reference to the new js file from my _Layout file right after the unobtrusive.validate script inclusion line.

<script src="@Url.Content(" type="text/javascript"></script><script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

SQL Query to find tables by name and column

This script will find tables where the table name is like a value and it contains a column name that is like some value

SELECT TABLE_NAME as TableName , c.Name as ColumnName
FROM INFORMATION_SCHEMA.TABLES ist 
join sys.tables st on 
ist.TABLE_NAME = st.name 
join sys.columns c 
on c.object_id = st.object_id 
WHERE (1=1)  
and ist.TABLE_TYPE = 'BASE TABLE' 
and  ist.Table_Name like '%account%' 
and c.name like '%agent%'

KendoUI foreign key dropdown not showing

I have used the grid in many projects and I typically don’t have a problem with this, but on a recent project I couldn’t get the dropdownlist in the foreign key fields to show. There were several things I had forgotten to handle so let me document it to save a few hours in the future.

First, make sure that EditorTemplates exist in your project. There is a ForeignKey.acsx and .cshtml, so get those and might as well grab them all. These can be found in the example project from your initial KendoUI sample download.

editorTemplates

 

Next I had to make some additions to the main web.config and to the Views web.configs (make sure to alter the Views web.configs in the site root and in the Areas if you are using areas).

In the site web.config add this section:

mainwebconfig

 

In the Views/web.config (in the site root and in Areas) make sure the following is added within the system.web (not system.webServer) section:

ViewsWebConfig

At this point the dropdowns began working for my grids.