FAQ Database Discussion Community


Binding my view model to a view causes all check boxes to be checked

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
I'm having an issue where my all the check boxes rendered in the view are coming out checked. I put a breakpoint at the line where my view model is constructed and through the debugger, I can see that some values are set to "true" and others are set to...

Jquery Tabs - return selected tab dynamically

c#,jquery,asp.net-mvc,asp.net-mvc-4,razor
On page load I would like to display selected tab dynamically. This is so validation is displayed for the correct tab. I have the following code: <script type="text/javascript"> $(document).ready(function () { var selectedTabId= $("#SelectedTab").val(); alert(selectedTabId); $('#tabs').tabs( { cache: false, beforeActivate: function (event, ui) { selectedTabId = ui.newPanel.attr('id'); $("#SelectedTab").val(selectedTabId); }, selected:...

Asp.net mvc won't take the razor parameter

c#,asp.net,asp.net-mvc,razor
I'm developing on a school project where it has gone great so far but the problem has finally arrived. I have this method in my homecontroller: [HttpPost] public ActionResult GetSeatsInShow(int showId) { ... return View(realSeatList); } In my view I use razor to parse a parameter to the controller and...

How to correclty use Views in different folders. (The view 'Index' or its master was not found or no view engine supports the searched locations)

c#,asp.net,asp.net-mvc,entity-framework,razor
My App has 3 big modules, one for the global admin, one for the company admin, and one for the company user. I want to split this into folders, both in the controllers folder and inside the views folder. When I add the controller with scaffolding. http://screencast.com/t/zxK5kaWLY It will automatically...

MVC - Changing default text in dropdown

asp.net-mvc,razor,enums,html.dropdownlistfor
I have a view model that contains an enum: public class PasswordChangerIndexViewModel { public enum DatabaseTypes { Main = 10, Florida = 20, Illinois = 30, Missouri = 40, NewHampshire = 50, NewJersey = 60, Oklahome = 70 }; [DisplayName("Database")] public DatabaseTypes DatabaseType { get; set; } } And in...

Prefered way of building multi view layouts in ASP.NET MVC?

c#,asp.net,asp.net-mvc,angularjs,razor
I'm currently wondering about the prefered way to build multi view layouts using ASP.NET MVC. For example in angular-based SPAs, loading different views into a layout is pretty straightforward: <div ui-view="header"></div> <div ui-view="content"></div> .state("home", { views: { "header": { templateUrl: "app/_header.html" } ... However in MVC, there seem to be...

Disable Copy/Paste/Right Click in mvc TextBox

javascript,asp.net-mvc,razor
I have a textbox which accepts numeric value.This is handled using javascript. I'd like to disable copy, paste and right click functionalities for the text box. Any help would be appreciated. @Html.TextBoxFor(model => model.Days, new { @class = "input_box", @id = "txtDays", @onkeydown = "javascript:NumberOnly(this,event)"}) ...

Rendering “~/bundles/jqueryval”

c#,asp.net-mvc,asp.net-mvc-4,razor
I need your help, I have written this code to render the "~/bundles/jqueryval" The view Code @model workflow.DataHolders.NewCompany <link href="@Url.Content("~/sharedfiles/css/forms/addnew.css")" rel="stylesheet" type="text/css" /> <div id="Add_container"> @if (!ViewData.ModelState.IsValid) { <div id="validationMessage">Please Correct The Errors Below</div> } @using (Html.BeginForm("ValidateAndSignUp", "Accounts", FormMethod.Post)) { @Html.AntiForgeryToken() @Html.ValidationMessage("CompanyName"); <span...

check for value null on razor syntax

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,razor
The following code is failing because propiedadesFormularioDetalle is null. I placed an IF before the block code but still not working, if I remove one of the bracked, then it wont compile @if (propiedadesFormularioDetalle != null) { } <div class="panel panel-default"> <div class="panel-heading">Propiedades adicionales</div> <div class="panel-body"> <dl class="dl-horizontal"> @foreach (KeyValuePair<string,...

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...

ASP.NET Vnext Tag Helpers for Areas

asp.net-mvc,razor,asp.net-mvc-5,tag-helpers
I may use <a href='/Area/Controller/action'> </a> in asp.net vnext but just want to know whether we can use tag helpers like <a asp-controller="ControllerName" asp-action="ActionName" asp-area="AreaName"> to redirect to the specific file in the area. Will any one guide me how to redirect to a file in area using tag helpers.?...

Using Razor Syntax within JavaScript Conditional Statment

javascript,c#,asp.net-mvc,razor,conditional
In an index.cshtml I have the following working code similar to: <script type="text/javascript"> if ('@Model.SomeCondition' === 'True'){ Do Something(); } </script> The === 'True' seems like an odd hack to me to force Razor and JavaScript to get along. How can I refactor to use === true? This doesn't give...

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...

Is possible to create htmlhelpers dynamically?

javascript,html,asp.net-mvc,razor
I wanted to create a htmlhelpers elements depending on the value of dropdown list. Here is the code: Dropdown <select id="pracownicy"> <option value="biurowy" style="color: black">Pracownik biurowy</option> <option value="przewodnik" style="color: black">Przewodnik</option> </select> and script be like: <script> function pracownicy() { var x = document.getElementById("pracownicy"); if (x.value.equalTo("biurowy")) { } if (x.value.equalTo("przewodnik")) {...

MVC best practice for displaying static generated data

c#,asp.net-mvc,asp.net-mvc-4,razor
Question background: I have a two page MVC 4 web app. The first page's view currently has its data manually typed into the View as its static i.e nothing is being passed to the View from its associated Controller method, as shown: Index controller method: Public ActionResult Index() { return...

Partial View's checkbox state not returned to controller

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
I have a main view whose Model is of type FacilityViewModel. The main view loads a partial view that also contains a partial view. Both partial views have a model of type FiltersViewModel. The most nested partial view loops through a dictionary and creates a checkbox for each item to...

Disable select2 dropdown with knockout binding?

javascript,jquery,asp.net-mvc,razor,knockout.js
I have an MVC Razor project and in my view i have one Html.TextBoxFor with data-bind="disable: setRoot". This input is used by Select2 jquery plugin. My problem is that the disable binding is not working properly. This is my code: <div class="control-label">Category</div> <div class="input-group"> <div class="input-group-addon"><label><input data-bind="checked: setRoot" type="checkbox"> root</label>...

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