FAQ Database Discussion Community


How to validate textbox with checkbox in MVC?

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I have This ViewModel: public string Address { get; set; } [DisplayName("Do you want Reward?")] public bool IsReward { get; set; } [Range(0,int.MaxValue,ErrorMessage="Please enter integer number")] [DisplayName("Reward")] public int Reward { get; set; } In View IsReward property is unchecked by default, when user check Isreward and post the view,...

Delete Uploaded file in MVC5?

asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,model-view-controller
I'm working with an MVC5 project, I have created a simple system that the user can upload a file "CV" for each Employee. Now all thing work for me fine except "DELETING File". I need to add action method for deleting uploaded file and the ability to replace it with...

How to get started with Visual studio 2012

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,visual-studio-2012
I want to create web application using Visual Studio 2012. The application should login into a website and report numerical findings on the UI. The language used will be Visual C#. I have loaded the application and selected on the menu: File> New > Projects. A window appears with multiple...

How do I switch out a DropDownList with True and False and Not Set with a CheckBox in asp.net mvc3?

c#,asp.net-mvc-3,checkbox
I'm new to mvc and was wondering if there was a way to switch out a DropDownList with a CheckBox. In my database I've got a property with a datatype of bit. In Visual Studios, after I create my model and controller and run it, it shows up as a...

ICollection circular reference

c#,asp.net-mvc,linq,asp.net-mvc-3
I have a LINQ query like so var Data = from a in db.Medlem where a.Person.PersonId.Equals(BrukerCv.Person.PersonId) select new { a.Prosjekt.ProsjektId, a.Prosjekt.Navn, a.Prosjekt.Kunde, a.Prosjekt.TekniskProfil, a.MedlemId, a.Rolle, a.Start, a.Slutt }; and I want to return it like a json, so I use this return Json(Data, JsonRequestBehavior.AllowGet); but the problem I encountered is...

razor - binding issue with radio button

c#,asp.net,asp.net-mvc-3,asp.net-mvc-4,razor
I am struggling to bind ans for radio button i am doing a small project. I have two model Question and Answer. What i want to achive for pull a list of question and base on setting the user will have multiple choice or type the answer in a text...

Get a single text value using linq

c#,asp.net-mvc,linq,entity-framework,asp.net-mvc-3
I am using this line to return a value, but instead its getting a True var valor = valoresCampoAdicionalesEmpresa.Select(p => p.Key == propiedad.Nombre).First(); This the view data passes from the controller var valoresCampoAdicionalesEmpresa = (Dictionary)ViewData["ValoresCampoAdicionalesEmpresa"]; public ActionResult Edit(int? id) { var listFields = from b in db.Propiedades where b.Entidad.Nombre ==...

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

Post-build ditrective syntax

c#,asp.net-mvc-3,visual-studio-2012
I received this dreaded error, related to ClosedXML, when I deployed my project to the server. The project runs locally, though. Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. So I placed the "missing" DLL file...

Call an ActionMethod from one controller to another with HttpPost

asp.net-mvc,asp.net-mvc-3,http-post
I am looking at different ways to call an ActionMethod from Controller and I know that you can call an ActionMethod from One controller to another. However, we can see that some of the actionmethods are decorated with [HttpPost] and if we are calling these methods from the View then...

How To Pass UserIdentity/UserName From WebForm application to MVC5 Application?

asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,webforms
I have a asp.net webform application (ProA). It was built some time ago by someone else, although I can access source code. Now, I finished another application which is a MVC5 (ProB). ProA uses asp.net membership for authenticate users. ProB is not using any membership. Now, we want to add...

Html.TextBoxFor not submitting a value using HttpPost to controller

html,asp.net-mvc-3
This is a simple issue and something I've done before but I can't see why this isn't working. Here's my HTML helper: <%= Html.TextBoxFor(am => Model.Amount, new { @id = "myAmount" })%> I submit the form from the same view using a submit button: <input id="myprocess" type="submit" value="Submit" name="myprocess"> And...

Generate random number using c# and send voice call through twilio

c#,asp.net-mvc-3,twilio,twilio-click-to-call
I know how to generate a random number in C#. I read some article, How to send voice mail in Twilio. But my problem needs to send the message like this "Hey this is your access code 123456" The number 123456 will be different for different user. How do I...

MVC 4:How to display blank textbox for model property of integer when integer value 0..?

asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I am using variable in model like [Required] [RegularExpression(@"\d{5}-?(\d{4})?$", ErrorMessage = "Enter only 5 digit numbers.")] public int? Zipcode { get; set; } In View I am using @Html.DisplayFor(m => m.Shipping.Zipcode) I need to use only in @Html.DisplayFor....

How to get number of invoices for last 12 weeks in Postgres

sql,postgresql,asp.net-mvc-3,aggregate-functions,generate-series
Invoice database contains invoice dates: create table dok ( dokumnr serial primary key, invoicedate date not null ); Dashboard requires comma separated list containing number of invoices for last 12 weeks, e.q 4,8,0,6,7,6,0,6,0,4,5,6 List contains always 12 elements. If there are no invoices for some 7 day interval, 0 should...

How to assign roles from helper class,MVC5

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I am doing something like in action(Get), [Authorize(Roles = SmartRoles.smclientadmin,SmartRoles.smclientbranchadmin)] public ActionResult Index() { return View(); } And Helper Class public class SmartRoles { public static string smclientadmin { get { return smclientadmin; } set { smclientadmin = "SMClientAdmin"; } } public static string smclientbranchadmin { get { return smclientbranchadmin;...

Passing values in a view from controller after getting those values from same view [closed]

c#,asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I am new to MVC. I want to get "fromDate" and "ToDate" from a view. In the same view, I need three DropDownLists that are empty and hidden. After clicking on the submit button, those DropDownLists should be visible and filled with data based on the dates picked. But I...

Calling actionresult from view

asp.net-mvc,asp.net-mvc-3
This is my ActionResult() public ActionResult pay() { return View(); } [HttpPost] public ActionResult mytry() { return View(); } and this is my view pay.chtml @using (Html.BeginForm("mytry", "Home")) { <table> <tr> <td align="center"> <input type="button" value="submit" /> </td> </tr> </table> } I am not able to call the mytry() action...

Removing element using jquery

jquery,html5,asp.net-mvc-3,model-view-controller
I am using jquery token input in my program and according to a select list change i need to pass extra parameter to the search function. I am able to do it by below code. $("#service").on('change', '.act_type', function () { qq = $(this).val(); var id = $(this).attr('id').split('-'); $("#token-input-code-" + id[1]).detach();...

Unity.Mvc3 vs Unity.Mvc

asp.net-mvc,asp.net-mvc-3,unity
Using the Unity.Mvc3 with a Mvc 3 application, i could register my IDummyService as follows: container.RegisterType<IDummyService, DummyService>(new HierarchicalLifetimeManager()); On each web request, a new instance of my IDummyService is created (as explained in this article), but since I upgraded Mvc 3 to Mvc 4 and hense Unity.Mvc3 to Unity.Mvc, an...

how to check if a row is checked and a specific cell is empty using jquery?

javascript,jquery,html,asp.net-mvc-3
Basically when a user clicks submit in my MVC 3 application. I want to use jquery to check if any of the rows selected (selected via checkboxes) have any value in a particular cell in that row. and is not display an alert mgs or validation error. Rough code attempt:...

How to bind list of objects in ASP.NET MVC when one item in between is deleted

c#,asp.net-mvc,asp.net-mvc-3,c#-4.0,model-view-controller
I have an issue while Binding model To A List in MVC. My page has a functionality to add and delete text-box dynamically. My page HTML will be <form id="prdt"> <div id="div_0"> <input type="text" name="products[0].Name" value="Coffee"/><button id="0" onclick="return DeleteLocation(this.id)">Delete</button></div> <div id="div_1"> <input type="text" name="products[1].Name" value="Tea" /><button id="1" onclick="return DeleteLocation(this.id)">Delete</button></div> <div...

Compilation error whn loop in razor

c#,asp.net,asp.net-mvc-3,asp.net-mvc-4,razor
I am getting compilation error in the code below, it complaining about a bracket but all the bracket and matching up I am a bit lost can someone please help me here thank in advance. Error: Description: An error occurred during the compilation of a resource required to service this...

Controller.HttpContext.Request.Browser.IsMobileDevice is false on Production server

asp.net-mvc,asp.net-mvc-3
I have a MVC3 web application, I followed the instruction is below link to make my site mobile friendly, http://www.hanselman.com/blog/ABetterASPNETMVCMobileDeviceCapabilitiesViewEngine.aspx everything is fine on my local IIS and it works when I connect to my local site via Mobile device, I uploaded the site to the production server but it...

Unable to install MVC 3

asp.net-mvc,visual-studio-2010,asp.net-mvc-3,installation
I am attempting to install asp.net MVC 3 to use with Visual Web Developer 2010 Express. I try to install from AspNetMVC3ToolsUpdateSetup.exe. The install log shows this: MSI (s) (08:E4) [00:22:35:745]: Product: Microsoft ASP.NET MVC 3 -- A later version of Microsoft ASP.NET MVC 3 is already installed. Setup will...

Complexe Date Query SQL

mysql,sql,asp.net,asp.net-mvc-3,razor
I would like to add a Date filter to this code: var db = Database.Open("Tool") ; var selectCommand = "SELECT Nom, COUNT(Nom) FROM DTool2 AS NumberOfOrders Group by Nom "; var selectedData = db.Query(selectCommand); var grid = new WebGrid(source: selectedData, defaultSort: "Column1", rowsPerPage:200); grid.SortDirection = SortDirection.Descending; The date would be...

how to overload controllers in MVC

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-routing
I am trying to overload the MVC controllers, how can I overload it properly? I want to list all companies in my website in a ListCompanies() controller like below http://localhost:21047/Home/ListCompanies and I want to add search criteria if user makes a search like below http://localhost:21047/Home/ListCompanies/sera "sera" is my search criteria....

ASP.Net MVC and state - How to update the database from Session changes in dual listboxes?

c#,asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I am working on a dual listbox system where the operator can assign and remove different exercises to a specific users regime. For the RemoveExercises function, i have started using a Session so that the RequestedExercises listbox is updated with the changes made (the adding and removing of exercises). Currently...

(ASP.NET MVC) Files Served in the Browser Have No Extension

asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,mime-types
I have the following code that serves the file to the user in the browser. The served file has no extension, and the users have to add the extension manually in order to open it. public ActionResult OpenDoc(int id = 0) { Document doc = dbContext.Documents.Single(d => d.DocID == id);...

How to run ASP.NET MVC project inside another ASP.NET MVC project

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,web-config
Let's say I have a MVC project where there is root folder MVC2 and. Now, I want another MVC project to that MVC2 folder and serve it. Below url should serve MVC2 project which is just a folder inside the root project. Root project is also MVC. currentSite.com -> current...

Inherited Property of Model is always returning Null Value

c#,asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-5
I have a view which displays a radiobutton list on left side of the page and it also loads a partialview on right side of the page which consist of various filters to be selected before displaying a report in a popup window. The problem is that the property named...

How to pass strongly typed complex object to ajax method in mvc3

jquery,ajax,asp.net-mvc-3
I have a model class called ReferralModel that which has properties that consist of other objects: public class ReferralModel { public Referral Referral { get; set; } public Address Address { get; set; } public Patient Patient { get; set; } } Here is a sample of the Address class:...

When removing model data from a db everything but the primary key is getting deleted, how can i remove all of it?

c#,asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I am working on a listbox system where the operator can select exercises in a users regime and delete them. Currently when RemoveExercises is called it deletes all of the data associated with the RegimeItem but the RegimeItemID. For the RemoveExercises function, i have started using a Session so that...

Do I need separate domain for MVC Web API?

asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,c#-4.0,asp.net-web-api2
I am facing one problem. I have 1 Presentation Layer Project using ASP.NET MVC. There is another project for Database interaction for MVC Web API. Question: Do I need two domains ? One for ASP.NET MVC Project and another for MVC Web API project ?...

Another way to do @Html.LabelFor(m=>m.myField), to get the Field Title without surrounding elements?

asp.net-mvc,asp.net-mvc-3,razor
I am using MVC3, ASP.NET 4.5, Razor. Normally I would use, to get a standard title for my DB columns: @Html.LabelFor(m=>m.myField) Which would produce: <label for="myField">MyField Title</label> However I need to produce just "MyField Title" which will exist in some "th" elements such as: <th>MyField Title</th> So I need some...

Remote validation doesn't work when property to validate is inside a modal Bootstrap

asp.net-mvc,asp.net-mvc-3,data-annotations,bootstrap-modal,remote-validation
I'm using ASP.NET MVC3. When an user create an account, I need the chosen nickname be unique, so I use the Remote DataAnnotation like this : public class UserModel { [Required] [Remote("CheckNickname", "Validation", ErrorMessage = "This nickname is already used")] public string Nickname { get; set; } // ... }...

How to check if ViewBag property is null or not exists

c#,jquery,asp.net-mvc,asp.net-mvc-3,razor
I have a requirement to execute a script in document.ready function if viewbag property is null or not exists. Below is the code i wrote to check if viewbag property not exists. i used recommned approached where you @ViewBag.Property!=null but when i do that i get an error saying name...

Asp.net mvc 4 jquery ajax request return internal server error

jquery,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,asp.net-ajax
I tried to establish ajax request to asp.net mvc controller , but it give me internal server error // My Products Controller [HttpPost] public ActionResult FilterCategeory(int prodID) { var categs = new Categ() {PROD_ID=prodID }.Search(); return Json(categs); } //My ajax request $("#categs").empty(); var prm = $("#prods").val(); $.ajax({ type: "POST", url:...

Url.Content does apparently not expand dynamically generated string

.net,asp.net-mvc-3,razor
I'm trying to dynamically generate image path's based on an external variable in a razor view. I've seen other questions like this, however they did not seem to address my particular problem. There seem to be an issue with the order in which razor resolves the resulting string. If I...

How to create an input (editorfor) for a field not in the model

c#,asp.net-mvc,entity-framework,asp.net-mvc-3,razor
I have the following on my EDIT view @model Inspinia_MVC5.Areas.GlobalAdmin.Models.Empresa @{ ViewBag.Title = "Edit"; Layout = "~/Areas/GlobalAdmin/Views/Shared/_LayoutGlobalAdmin.cshtml"; var camposAdicionalesEmpresa = (List<Inspinia_MVC5.Areas.GlobalAdmin.Models.Propiedad>)ViewData["CamposAdicionalesEmpresa"]; var valoresCampoAdicionalesEmpresa = (Dictionary<string, string>)ViewData["ValoresCampoAdicionalesEmpresa"]; } and my controller is like this: public ActionResult Edit(int? id) { var listFields = from b in...

Mixing HTML and Razor Code Within Nested Conditionals

c#,asp.net-mvc-3,razor
I am trying to use Razor withh a few nested conditionals, which is by far the most complex intermingling of Razor and HTML I have attempted thus far and I admit that I am not an expert with Razor yet. I am getting Razor parsing errors of this type: "Only...

BaseController uses for what in MVC?

asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,model-view-controller
I look more tutorial about MVC. But I didn't understand, people are using "BaseController" for what? In one project someone use it forcommunication between all controller. In other project someone use for get logs. Can you explain to me completely?

calling a MVC 3 Apicontroller from another website

asp.net-mvc-3,api,web
I have a mvc 3 api controller in my project namespace Carabistouille.Controllers { public class CarabistouilleController : ApiController { /// <summary> /// Method to retrieve all of the carabistouille in the catalog. /// Example: GET api/carabistouille /// </summary> [HttpGet] public HttpResponseMessage Get() { IEnumerable<Carabistouille.DB.Carabistouille> list = Carabistouille.DB.CarabistouilleDAL.GetAllCarabistouille(); if (list !=...

Group the viewbag items while rendering in view in MVC3

asp.net-mvc,asp.net-mvc-3
I am new to MVC. We have a list of owners. Each owner has details like name, address and class(based on his income). In MVC controller, I am storing the list of owners in a viewbag. I want to group the owners who are having the same class while rendering...

Razor showing property name instead of value

c#,asp.net,asp.net-mvc-3,asp.net-mvc-4,razor
I Just start MVC and razor, i am having an issue for displaying data, the controller is return a list of collection data in the view when im trying to display on the UI it showing the property name instead of the data. for exmaple @Html.LabelFor(M =>M[i].Questions) is suppose to...

Passing list from view to controller MVC3

forms,list,asp.net-mvc-3,post
after deep searching I couldn't find any solution. I have a Ajax.BeginForm which needs to pass a list containing information about the checked rows. UnitsChecked Class (Model) public class UnitsChecked { public bool IsChecked { get; set; } public TaxiTV.Data.Entity.Unit Unit { get; set; } } ReportsVM (View Model Class)...

primary key column not visible by default

asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,model-view-controller
I am learning ASP.NET and trying to create two table using code first approach using MVC. Below is the model .cs file for Courses. public class Instructor { [Key] public string name { get; set; } public string address { get; set; } public string address_ { get; set; }...

MVC Radio button selected one

c#,asp.net-mvc,asp.net-mvc-3
I have radio button as below for some reason even though the first one is checked, always the last one shows up checked on the form page. Why ? How can i fix this? @Html.RadioButtonFor(model => model.IsSatisFied, Satisfaction.Not, new { @checked = "true" }) @Html.RadioButtonFor(model => model.IsSatisFied, Satisfaction.Maybe, new {...

An expression tree may not contain a dynamic operation but it's not telling me where

c#,asp.net-mvc-3,razor
I'm having an issue where I am getting the message: \OrderGas.cshtml(24): error CS1963: An expression tree may not contain a dynamic operation"} Here is my code for my web form: @using SuburbanCustPortal.MiscClasses @{ ViewBag.Title = "Order Gas"; } <h2>Order Gas</h2> @using (Html.BeginForm("OrderGasSuccess", "GasOrder", FormMethod.Post)) { @Html.ValidationSummary(true, "Submit was unsuccessful. Please...

how to prevent double post on click, when it takes long time to save to db?

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,model-view-controller
My problem : if i have a simple post request where i just change some Voodoo items in db on edit: [HttpPost] [ValidateAntiForgeryToken] [SessionStateActionFilter] public ActionResult Edit(MonkeyJar voodooMonkey) { if (!this.service.EditMonkey(voodooMonkey)) return RedirectToAction("Edit",voodooMonkey); return RedirectToAction("Index"); } Lets say that EditMonkey takes 1.5 second to respond, while those 1.5 seconds is...

Asp.Net MVC route action method doesn't call when there is a DOT (.) at the end of url

c#,asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
Configured Route: routes.MapRoute( name: "RedirectToProduct", url: "product/page/p{productId}/{shortName}", defaults: new { controller = "Product", action = "RedirectToProduct", shortName = UrlParameter.Optional } ); Action Method: public class ProductController : Controller { public async Task<ActionResult> RedirectToProduct(string productId, string shortName) { } } Problem.. When I hit url http://localhost:1234/product/page/p1185/ , then I am getting...

RegisterRoutes in Global.asax

c#,asp.net,asp.net-mvc,asp.net-mvc-3
I dont understand the RegisterRoutes perfectly. Lets assume the browser's current URL is //Home/ListCompanies/{filter} http://localhost:21047/Home/ListProducers/Yerli we came to the address above with the link below @Html.ActionLink("Yerli Markalar", "ListProducers/Yerli", "Home") And I have a link on the current page like below @Html.ActionLink("Bayiler", "ListCompanies", "Home") http://localhost:21047/Home/ListCompanies/Yerli But when I hover on the...

How to create edit view with a dropdownlist

c#,asp.net,asp.net-mvc,entity-framework,asp.net-mvc-3
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 {...

Create view for a child-master relationship

c#,asp.net,asp.net-mvc,entity-framework,asp.net-mvc-3
I have an entity called Entity, (lol). public class Entidad { [Key] public int Id { get; set; } public string Nombre { get; set; } public virtual ICollection<Propiedad> Propiedades { get; set; } } I also have an entity called Properties public class Propiedad { [Key] public int Id...

Kendo dropdownlist binding event inside grid client template

c#,asp.net-mvc-3,razor,kendo-grid,kendo-dropdown
Am trying to add a dropdown inside the kendo grid. And I need to add it inside the clienttemplate instead of editortemplates as i need the whole grid to be in edit mode on loading itself. And this is the way i did it. .ClientTemplate("<input class='pUomDdl' #= UOMCodeEnabled ? disabled='disabled'...

how to load set of HTML files in ASP.NET MVC view [closed]

c#,asp.net,asp.net-mvc,asp.net-mvc-3
I have some training modules which I want to load from my MVC site (SSL). I am trying run them as following but it does not load their css and images. Also I am not sure if it will let me to move to other html pages with in the...

Item added to DbContext twice

c#,database,asp.net-mvc-3,entity-framework-4
I am very new to SP.NET MVC, so excuse me for missing basic stuff. I have created a website working with a database (Microsoft SQL Server) and I'm using Entity Framework package to manage it. I have a DatabaseManager class as following: Public class DatabaseManager : DbContext { Public DbSet<Connection>...

POCO Model and Calculated fields

asp.net-mvc,entity-framework,asp.net-mvc-3,asp.net-mvc-4
I have POCO entities based on the database model (example: Company entity is based on Companies table). In order to display a couple of calculated fields in the view, I added corresponding properties in the ViewModel. Should I have these calculated fields in the Model(POCO entity) itself or Should I...

HTTP 404. The resource you are looking for

asp.net-mvc-3
Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested...

ajax success returning undefined data object

c#,jquery,ajax,asp.net-mvc-3
I am returning a view from my action method which is called by ajax call. but in ajax success it is returning undefined object. What is the Problem? $.ajax({ type: "GET", url: url, success: function (data) { if (typeof (data) === 'undefined') { alert("Error"); return; }else { $('#content').html(data); } },...

Getting the latest version of MySQL for EF6

c#,mysql,asp.net-mvc-3,entity-framework-6,mysql-connector
For my website I am using MySQL for EF6. When I set it up, I was told to use the 6.8.3 version, so I have MySql.Data v6.8.3 and MySql.Data.Entity.EF6 v6.8.3 that I installed via Nuget. Here's the values from my packages.config file: <package id="MySql.Data" version="6.8.3" targetFramework="net45" /> <package id="MySql.Data.Entity.EF6" version="6.8.3"...

How to concatenate variables in razor?

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,razor
I would like to concatenate the 'Name' and 'LastName' of the user profile that I fetch from the database. I have the following code in Razor: @if (Request.IsAuthenticated) { var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())); var currentUser = manager.FindById(User.Identity.GetUserId()); var fullName = @currentUser.Name + " " + @currentUser.LastName; @fullName;...

MVC Navigation Design

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,model-view-controller
What is the best method to render some navigation hyperlinks depending on which page the user is on (I am using C# MVC 4). I have a _layout.cshtml which looks like the following (shortened down for display purpose). <body> @{Html.RenderAction("MainNav", "Navigation");} <div id="container"> @RenderBody(); </div> </body> If a user navigates...

Authorization in Cloud Applications using AD Groups issue with new group

c#,asp.net,asp.net-mvc,asp.net-mvc-3,adal
I have an asp.net mvc application and my code is based on this article: http://www.dushyantgill.com/blog/2014/12/10/authorization-cloud-applications-using-ad-groups/ and on this sample code: https://github.com/dushyantgill/VipSwapper/tree/master/TrainingPoint I created a controller for the global admin public class GlobalAdminController : Controller { // GET: GlobalAdmin [AuthorizeUser(Roles = "admin")] public ActionResult Index() { return View(); } } and...

HTML file download using MVC FileResult looks different when downloading from server

asp.net-mvc,asp.net-mvc-3
I have written some Asp.Net MVC code that returns an Html file FileResult. var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(htmlReport); writer.Flush(); stream.Position = 0; return File(stream, "text/html", fileName); Using my local environment the HTML file looks fine when opened but after deploying to the server and...

razor MVC foreach with @using (html.beginform())

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,razor
I need to create a form with a question and a text box to allow user enter their answer and send for validation. It seems @using (Html.BeginForm()) is not valid with @foreach. Below is the code but I am not sure if this is the correct way. Can someone point...

how to get post tags in mvc actionresult

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I have this ViewModel: public string Title { get; set; } public string Description { get; set; } public int City { get; set; } and in View ,Users can Add some tage like as this : book,story,c#,... All tags in view in Li in UL. How can I get...

Restrict the global variable should not take assign value which is done outside the class intialization

c#,asp.net-mvc-3
I have one global variable isSave in my controller. private bool isSave; There is Get Method in samecontroller. I want that viewbag given below should be true/false based on condition ViewBag.EmailConfirmationSent = false; [HttpGet] public ActionResult Index() { if(!isSave) ViewBag.EmailConfirmationSent = false; } There is post method in same controller...

Ajax.BeginForm is always excecuting a 'POST'

jquery,ajax,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I have two ajax forms: @using (Ajax.BeginForm("Index2","Home", new AjaxOptions { UpdateTargetId = "result", HttpMethod = "PUT" }, new { onclick = "Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));", onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'PUT', updateTargetId: 'result' });" })) { <input type="hidden" name="id" value='1'/> <input type="submit" value="OK Put" /> } @using (Ajax.BeginForm("Index2","Home", new...

Image displaying error from database

asp.net-mvc,angularjs,asp.net-mvc-3
After the recent changes in my application still i get this issue while displaying the image using the relative path in the database. Error: 404 NOT FOUND http://localhost:1256/Empdet/%22/Photos/jobs.jpg%22 Controller.js: $scope.UploadFile = function () { console.log('UploadFile'); console.log($scope.Empdet.PhotoFile); var file = $scope.Empdet.PhotoFile; console.log('file is ' + JSON.stringify(file)); var uploadUrl = "../Photos"; console.log('before...

.Submit() not working

jquery,asp.net-mvc-3,form-submit
I have a from skeleton like below @using (Html.BeginForm("Preapprove", "Preapproval", FormMethod.Post, new { name = "form1", id = "form1", enctype = "multipart/form-data", @class = "form-horizontal" })) { ...... <input name="submit" type="button" value="Submit" id="Sub" class="btn btn-success" style="margin-left:950px" /> } And in jquery im submitting this form on the click even of...

Image Gallery control not loading

asp.net-mvc-3,image-gallery,devexpress-mvc
I am currently working on a project that has decided to incorporate Image Gallery from DevExpress MVC. Previously when put into the page, we had an bug come up where if the SettingsFullscreenViewer.Visible was set true, you could not upload. However, once turned to false, we could upload and do...

'System.Web.HttpApplication.User' is a 'property' but is used like a 'type'

c#,asp.net-mvc,asp.net-mvc-3,roleprovider,user-roles
I am new to MVC3 and I am trying to implement customer user and role Authentication. I am able to validate the user using my custom database but now I want to use my custom roles out of the same table. I followed the instructions from this link below to...

If the Model should contain all of the business logic, what is the best way to call class methods in the Model? (more inside)

asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
Alright, so I have always read that in ASP.NET MVC one should always put the business logic in the model. So let's say I have this model class: public class CarModel { [Display(Name = "Car Manufacturer")] [Required(ErrorMessage = "A Car Manufacturer is required")] public string CarManufacturer { get; set; }...

Returning more than just one model to the View?

asp.net-mvc,asp.net-mvc-3,model-view-controller
I am fairly new to MVC, and I've been reading a bit about ViewModels, but how do I go about sending two models to my View, where the queries are like so public ActionResult Index(int Id) { var People = from a in db.Person select a; var Data = from...

Cutomized DisplayFormatAttribute only setting once

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4
I am setting NullDisplayText in the DisplayFormat from resource through the following code public class LocalizedDisplayFormatAttribute : DisplayFormatAttribute { private readonly PropertyInfo _propertyInfo; public LocalizedDisplayFormatAttribute(string resourceKey, Type resourceType) : base() { this._propertyInfo = resourceType.GetProperty(resourceKey, BindingFlags.Static | BindingFlags.Public); if (this._propertyInfo == null) { return; } base.NullDisplayText = (string)this._propertyInfo.GetValue(this._propertyInfo.DeclaringType, null); }...

How to add checkboxes to each day in this calendar view?

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,calendar
I am trying to add a simple checkbox feature to each day in my calendar view. It must be inline with the style of the current calendar and when a bool is selected it must be able to save the changes to the database. Any suggestions would be appreciated. My...

How to increase performance of foreach loop

c#,asp.net-mvc-3,loops,foreach
I'm using a foreach loop to calculate answers against question. It calculates all the answers against a question but when it loads the next question it takes one minute every time. How can I reduce this time? List<Questionnaire> myQuestionnaires = report.Project .Questionnaires .Where(q => q.Active) .ToList<Questionnaire>(); foreach (Questionnaire q in...

Error when doing two calls from DB

c#,asp.net-mvc,oracle,asp.net-mvc-3
I'm getting the error "Cannot acess to disposable object" when I try to use the same connection. So this is my Oracle context: public class MyOracleContext { DbConnection connection; public MyOracleContext() { connection = new OracleConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); } public TOut ExecuteCommand<TOut>(IDbCommand command, Func<IDataReader, TOut> mapHelper) { TOut result = default(TOut); try...

Why does this dapper query return null?

c#,mysql,asp.net-mvc-3,dapper
I have a mysql statement that I am passing to the dapper query method and it is returning a null object. I have created a POCO class to hold the returned result. I tested the query directly through a sql editor and it returned a result. Here is the code:...

Space in attribute value gets replaced by " (quotation mark)

html,asp.net,asp.net-mvc,asp.net-mvc-3,razor
When I insert a string with whitespace as an attribute value it gets replaced by a quotation mark. For example, @foreach (string file in files) { <div class="item active"> <img class="img-responsive" [email protected] alt="Book cover"> </div> } It gets rendered as <div class="item active"> <img class="img-responsive" src="c:\users\raghav" sharma\documents\visual="" studio="" 2013\projects\bookhive\bookhive\content\images\0007282311-1.jpg="" alt="Book...

error occurred during a cryptographic operation .net framework 4.5.1

asp.net,asp.net-mvc-3,form-authentication
I am using angularjs and Web API. In order to authenticate user, I use FormAuthenticationTicket (I just create the ticket with user data, encrypt it and then return to the client). When the client sends request he adds this encrypted cookie to the header of his request. On remote server...

Need Javascript or jquery code to pass data to controller

javascript,jquery,asp.net-mvc-3,asp.net-mvc-4
Everytime <a> tag is pressed i need to submit form. I need to keep track the number of times <a> tag is pressed. It starts with 3 and every time its is submitted we increment by 6. I need to pass this number to GetArticleData Controller using Action Method. @{...

ASP.NET Compilation Tool not compiling .cshtml files

asp.net-mvc,asp.net-mvc-3,razor,aspnet-compiler
@echo off C: Cd \ Cd Windows CD Microsoft.NET CD Framework CD v4.0.30319 set /p phyPath= Enter Physical path in double quotes:- set /p virPath= Enter Virtual path in double quotes:- aspnet_compiler.exe -p %phyPath% -v / %virPath% -u echo process completed pause I'm using the above script in a batch...

What is an area parameter in Html.Action class?

asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,asp.net-mvc-5
I am studying ASP.NET MVC4. I don't quite understand what the area parameter is in the code below. <section id="myWorkingSection"> @Html.Action("myActionName", "myController", new { area = "Widgets", workingSection = "myWorkingSection" }) </section> myActionName takes workingSection as parameter but it does not take area as parameter. My guess is that since...

ObjectContext is disposed, can not longer used

c#,asp.net-mvc-3,entity-framework-6
Example Code: private static list; public void SetList () { var query = Container.Advices.Where (); list= query.ToList(); } public void doStuff () { var temp= list.where (...).ToList (); } problem situation: When i call the first time SetList, all worked fine. Now, a second is SetList called. I can see...

Space between rows in bootrap form not correct

html,css,asp.net-mvc,asp.net-mvc-3,bootstrap
I have the following form, however there is an extra space between 1st and 2nd row. http://screencast.com/t/brkYad2NjPaH However I am not sure how to get rid of it. This is the html code generated <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-md-2" for="Entidad">Entidad</label> <div class="col-md-10"> <select name="Entidades" class="form-control m-b" id="Entidades"></select> </div>...

DbContext has been disposed, does not make any sense

c#,entity-framework,asp.net-mvc-3
I am creating an C# Web application, where I would be able to add companies and the places the company has its branches. A company could have several location branches. And for one location there could be several companies. So the relationship between Companies and Territory is Many-Many. This is...

how to achieve Role based authorization in mvc3? [closed]

c#,asp.net-mvc-3
i stuck with Role based authorization in mvc3 i search lot in internet but did not find useful doc so please help me.. and please help me to create role in Asp.net membership

MVC3 Site Compiler Error

c#,asp.net-mvc,asp.net-mvc-3,compiler-errors
I'm new to ASP.NET MVC and I have inherited a project. I am trying to just publish the site to the staging server so I can test things. I had gotten it to publish successfully, and the site came up fine, but once you log in I get the following...

'System.Web.Mvc.HtmlHelper' has no applicable method named 'Partial'

c#,asp.net-mvc-3,debugging
I am getting this error: error CS1973: 'System.Web.Mvc.HtmlHelper' has no applicable method named 'Partial' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax."} From what I read here...

How to return partialView in OnActionExecutiong?

c#,asp.net-mvc,asp.net-mvc-3
Im a bit confused if some session variable is empty i want to result in to a partial view instead of redirectResult. Is it possible? if so how? i can see that there are a PartialViewResult, but i cant figure out how to use it. public class XXActionFilter : ActionFilterAttribute,...

How do I add ASP.NET MVC 3 Web Application in Visual Studio 2013?

visual-studio,asp.net-mvc-3
How do I add ASP.NET MVC 3 Web Application in Visual Studio 2013? ...

How to implement client side validation in MVC with chosen.js

jquery,asp.net-mvc-3,jquery-chosen,client-side-validation
I am using chosen.js for multiple selection, implemented with asp.net mvc3. Client side validation is not working this multi select control. The way I implement is, using Html.Dropdownlist helper and once the dom loaded from JavaScript $("#dropdown1").chosen(). It is replacing the Select with div's. Below is the code callback code...

Discrepancy between DB Query count in Glimpse HUD & SQL Tab

asp.net-mvc-3,glimpse
This question concerns Glimpse.MVC3 and Glimpse.EF5 packages. I'm trying to debug performance issues on an old MVC3 site. According to Glimpse's HUD, a particular GET request has 12 queries at 28ms total - but when I expand to open up the Main Panel, and click the SQL Tab, it says...

How to add a display name to mail sent via SMTP

c#,asp.net-mvc,asp.net-mvc-3,smtp,webmail
I am sending mail via gmail SMTP account by adding below in Global.asax file - WebMail.SmtpServer = "smtp.gmail.com"; WebMail.SmtpPort = 587; WebMail.EnableSsl = true; WebMail.UserName = "[email protected]"; WebMail.From = "[email protected]"; WebMail.Password = "nopassword"; WebMail.SmtpUseDefaultCredentials = false; When I send a mail through WebMail.Send() method, the mail is sent properly, but...

DB setup (use of 1 contact table for multiple tables)

c#,sql-server,database,entity-framework,asp.net-mvc-3
The question below is related, but no answer is provided: Single Contact table for multiple entities I have a contact table which has columns: id(PK), phone1, phone2, email1, email2, fax1, fax2 I also have 3 other tables: SUPPLIER, PERSON and CLIENT I want to use this 1 contact table in...

How to implement plugins/addons in Asp.net MVC?

c#,asp.net-mvc,asp.net-mvc-3,model-view-controller
I cant really get my head around one of the features i have to implement. Customers can have a bunch of addons which they pay for (list of addons is inside the db table). I have to implement functionality which only show plugins which customer had payed for. I know...

I'm using ninject 3.0 and asp.net mvc 3. I get the error rror activating IProductRepository

c#,asp.net,asp.net-mvc,asp.net-mvc-3,ninject
I am new to MVC so im fallowing a book example. But when I run the program it gives me the error: Error activating IProductRepository No matching bindings are available, and the type is not self-bindable. Activation path... I have read a bunch of articles and other error like this...

Facing crash when Posting the data to MVC WEB API Controller from Class Library project

c#,asp.net-mvc-3,asp.net-mvc-4,c#-4.0
Facing issue while posting the data to MVC Web API controller through Class Library project. MVC Web API is hosted on Localhost at Port 84. Class Library Code that sends request public String Put(OM_ServicesType obj) { string URI = "http://localhost:84/WebAPIServiceType/Put"); String myParameters = "ServiceType=qa&description=qa&Sid=1"; using (WebClient wc = new WebClient())...