FAQ Database Discussion Community


Getting and passing MVC Model data to AngularJS controller

javascript,asp.net-mvc,angularjs,razor,asp.net-mvc-5
Hey guys so I'm pretty new to AngularJS and I'm at a loss here. Right now my MVC program uses Razor to display all the data in my .mdf database (i.e: @Html.DisplayFor(modelItem => item.LastName) ). However, I want to go mostly Angular. I am trying to use ng-repeat to display...

dynamic generation of CSS attributes in CSS files based on user input in ASP MVC

c#,css,asp.net-mvc,razor,themes
Most of the dynamic CSS Q & A show how to swap between CSS files or predefined CSS values. My question is: during a live user session how to compute/compile CSS values for e.g. both element.width2 and width:230px into the CSS file (element.width3 and width:430px;) before loading it to the...

Is it possible to add views to deployed .NET MVC Razor site

asp.net,.net,asp.net-mvc,razor
Is it possible to add Razor views to a deployed .NET MVC site? How would you do this?

ASP.NET MVC DropDownList NullReferenceException

c#,asp.net-mvc,razor
Im having a problem with my dropDownList giving me a NullReferenceException and I don't know why. I want to post a post where you can choose with the DropDownList which Category it belongs to. Here is some of my code: PostModel public class Post { [Key] public int PostID {...

POST to MVC controller IEnumerable nested Model is null when I don't select checkboxes in order

c#,asp.net-mvc,razor,visual-studio-2013,asp.net-mvc-5
When I'm trying to get values in Post the values of checkboxes are set to NULL when I don't check then in order (1, 2, 3, etc). I need to select any of them in no order (i.e. 4, 5). MODEL: public class AssignUsersViewModel { [Display(Name = "Check to select")]...

MVC Hidden field via HTML Helper in Form Post issue

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
I have an issue when using a hidden field in an MVC Form Post. When the hidden field is generated via a HTML Helper it won't preserve it's value during the postback. But when using a HTML tag, it works. Unfortunately this one has taken me a whole day to...

Why does my MVC binding stop working when I assign a nested model to a variable?

c#,asp.net-mvc,asp.net-mvc-4,razor
I have code something like this contrived example in my MVC 4 razor view: @for (int i = 0; i < Model.NestedModel.Count; i++) { @Html.HiddenFor(model => modelModel.NestedModel[i].Id) @Html.EditorFor(model => Model.NestedModel[i].SomeProperty) } In which case everything works fine for me However, I wanted to tidy this up a little as the...

Display a tooltip with Html helper

html,asp.net,.net,asp.net-mvc,razor
I'd like add a tooltip to my razor view like this : @Html.Editor("Password", new { Title = "Doit contenir au moins une lettre majuscule, une minuscule, un chiffre et un caractère spécial" }) It is not working, If I just change the html helper by the input html tag, it...

Kendo Grid Date is null for 13/06/2015 all dates after 12

asp.net-mvc,razor,kendo-grid,kendo-asp.net-mvc
My grid: @(Html.Kendo().Grid<IBATechnologies.IBA.Web.Models.AssetTransactionDetailViewMod el>() .Name("transactionGrid") .Pageable() //.Editable(editable=>editable.Mode(GridEditMode.InLine)) .Columns(colums => { colums.Bound(p => p.assetCode).Width(100); colums.Bound(p => p.assetDesc).Width(100); colums.Bound(p => p.remark).Width(100); colums.Bound(p => p.currencyCode).Width(100); colums.Bound(p => p.rate).Width(100); colums.Bound(p => p.currencyRate).Width(100); colums.Bound(p =>...

In MVC Razor, how can I correctly add querystring parameters to an html.actionlink?

asp.net-mvc,razor,asp.net-mvc-5
I have an MVC Razor page where I am trying to add a querystring parameter to the URL. <td> @Html.ActionLink(item.Student_Name, "Index", "FourCourseAuditDetails", new { filterByStudent = item.Student_Name}) </td> My desired outcome is: http://[server]/FourCourseAuditDetails/Index?filterByStudent="[item.Student_Name]", but when I test out the page, the anchor href attirubte looks like this: http://[server]/[route of current...

Razor foreach loop loses item property

c#,asp.net-mvc,razor
I am creating a dynamic radio button group based on a selectlist within my model. when I pass a model to the View I want it to have the radio button selected based on the selected property of the selectlist. Here is what I have in the View: @foreach (var...

Object reference not set to an instance of an object. with a non null object.

c#,asp.net-mvc,razor
Ok I'm having this problem that is driving me crazy, I'm doing a search for a website, and it works great on my machine but when I upload it to gearhost it just blow with this error : Object reference not set to an instance of an object. Description: An...

how to interpolate property names with razor

c#,asp.net-mvc,razor
Let's suppose I have an array of objects myObjects whose string properties are Alpha, Beta, Gamma, ... In my View I could display the content with Razor like this <ul> @foreach(obj in myObjects){ <li>@obj.Alpha</li> <li>@obj.Beta</li> <li>@obj.Gamma</li> ... } <ul> But if I want to compact the code, passing an array...

'System.Web.Mvc.SelectListItem' does not contain a property with the name 'id' #2

c#,asp.net,asp.net-mvc,entity-framework,razor
I have the following entities: public class Entidad { [Key] public int Id { get; set; } public string Nombre { get; set; } public virtual ICollection<Propiedad> Propiedades { get; set; } } public class Propiedad { [Key] public int Id { get; set; } public virtual Entidad Entidad {...

Is it possible to append html to a class or div using razor syntax

razor,html-helper,asp.net-mvc-views
I am coding a MVC 5 internet application and have a question in regards to accesssing html classes or divs via razor syntax. Is it possible to access a html class or div via razor syntax and append some html code to the class or div? Is there a html...

How to Implement Dependent Dropdownlist in MVC4 Razor and using SQL server also

sql-server,asp.net-mvc-4,razor
I've 2 Dropdownlist called States and Country. but only the States DDL(DropdownList) will be enable the country DDL will be diable. when I select a option in States which is already stored in SQL. The Country DDL Should Show the Selected state's Country automatically from DB. Please help Me..... Ex:If...

How do I create an editor template that works with existing data?

c#,asp.net,asp.net-mvc,forms,razor
I created an editor template to display text boxes included in a form. @model WebApplication1.Models.PersonViewModel <input type="text" class="form-control" name="@ViewData.TemplateInfo.HtmlFieldPrefix" value=""/> I simply want to include the 'form-control' class in all my input text boxes used to collect data for this model. public class PersonViewModel { [UIHint("_TextFormControl")] public string FirstName {...

MVC aspx example (as an alternative to using razor) [closed]

c#,asp.net-mvc,razor
In all the MVC examples I have seen, the razor view is being used, however I have seen mentions of using aspx views, but I have not seen any examples of it in an MVC project. Are there any reasons that using MVC implicitly assumes that razor is going to...

Jquery: Change contents of