Questions tagged [asp.net-mvc-templates]

73222 questions
1

votes
5

answer
3.8k

Views

Kendo MVC fire Create method on Update call

I am using Kendo UI Grid with MVC 4 and it works great with only one exception. If I add a row in the grid, and after that update a row, It end up adding a row rather than updating it. What I can tell is that if I press add, the program enters the Create method in my MVC Controller, if I press Updat...
user1106784
1

votes
1

answer
990

Views

DropDownListFor<> not using my selected value if I change it in the model before call

Why does DropDownListFor not always set the selected value? In my case I've noticed this to happen when the dropdown list is being constructed after a form post and the value differs from the value that was submitted. So the scenario is a form containing a dropdown to select a category you want to s...
John Freebs
1

votes
2

answer
188

Views

root directory of MVC not found

I'm new to MVC4 (or MVC at all using .NET). I have my controller and views working fine but if I navigate to http://localhost: I get a 404. If I go to " http://localhost:/MyController everything works fine. How do I get a default controller for ROOT of the website?
Randy R
1

votes
1

answer
14.8k

Views

How to send multiple parameters using Html.BeginForm() in asp.net mvc?

Actually I want to send the image and the text in the textbox to the controller... @using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })) { @Html.Label("UserName:") @Html.Label("Upload:") Preview } and I am trying to retrieve them in the controller i...
Bharat Bhushan
1

votes
2

answer
4.3k

Views

Pass other value when checkbox is clicked

I want to pass other value when checkBox is clicked. my code is as below foreach (var item in Model) { @Html.CheckBox("Project", false, new { item.ProjectId}) } Controller is [HttpPost] public ActionResult Test(FormCollection collection) { var test = collection["Project"]; } in Var test i am get...
user2739679
1

votes
3

answer
10.7k

Views

Request.IsAuthenticated Return False all the time

I am having an issue with my Request.IsAuthenticated always return false. I am setting the AuthCookie CurrentRequest currentRequest = null; if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redi...
Josiane Ferice
1

votes
2

answer
594

Views

Implicit reference to object under construction is not valid when calling another constructor

I am trying following Within my MVC Controller: Private ProductRepoitory As IProductRepository Sub New() Me.New(New productsRepository(New ModelStateWrapper(Me.ModelState))) End Sub Sub New(ByVal repo As productsRepository) ProductRepoitory = repo End Sub However this line throws following Error mes...
highwingers
1

votes
2

answer
6.8k

Views

Loading javascript with MVC Razor

The following view is giving me "Object doesn't support prop or method jCarouselLite". I have an almost identical page using plain html which works. Am I loading the javascript properly? @using System.Web.Script.Services @{ ViewBag.Title = "Home Page"; } $(function () { // Add Carousel plugin to r...
WhiskerBiscuit
1

votes
2

answer
154

Views

Testing response time in Asp.net mvc4 application

I have an asp.net mvc4 application , in which i have this class public class Arbre { public int id_resp = -1; Admin notre_admin = new Admin(); List _la_liste = new List(); public Arbre(int id) { id_resp = id; } public List GetTasksOfExpert(int id_user) { List liste = notre_admin.GetTasksOfExpert(id...
Lamloumi Afif
1

votes
3

answer
1.9k

Views

how to restrict html table row height in WebGrid

html table one column contains lot of text and table looks ugly, there is too much space between rows. How to make table better so that there is not so much space, long column should be wider and maybe some of content not visible? I tried to use max-height , but it is ignored. Table is generated aut...
Andrus
1

votes
1

answer
1.8k

Views

Html.RenderAction fails in page after RedirectToAction()

I have a page "ViewUser". with this structure //display something about the user @{Html.RenderAction("UpdateUser", new { UserId = @Model.UserId });} //display some more stuff In the controller method for UpdateUser I have public ActionResult UpdateUser(int UserId){//populate form vars [HttpPost] pub...
user2472565
1

votes
1

answer
1.1k

Views

Ninject - Injecting singleton

I have this error when clicking a link on a site I'm creating Error activating IEntityCache using binding from IEntityCache to EntityCache No constructor was available to create an instance of the implementation type. Activation path: 4) Injection of dependency IEntityCache into parameter entityCach...
Sachin Kainth
1

votes
1

answer
3k

Views

ASP.NET MVC 4 Redirecting the Response in ActionFilterAttribute

so basically I have a custom ActionFilterAttribute and in it I override one method which looks something like this public override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext) { bool shouldEnter = true; string redirUrl = "SomeController/SomeAction"; // some checks here...
Dimitri
1

votes
3

answer
2.3k

Views

Umbraco, POST when inheriting from RenderMVCController

I have set up a document type in Umbraco, and have created a custom controller & model for this document type. The custom controller inherits from : RenderMvcController class and the views inherit the model through @inherits Umbraco.Web.Mvc.UmbracoViewPage This all works fine for any HttpGet request...
JanR
1

votes
2

answer
1.3k

Views

Input tag of type button is not changing color in an ASP.NET MVC view

In our ASP.NET MVC 4 app, we are using following HTML tag of type button in a partial view but the button is still showing the default background color instead of the one we define in the style attribute as shown below: We have checked that the class "myClass" is not doing anything related to CSS. I...
nam
1

votes
2

answer
2.4k

Views

Asp.net MVC RedirectToAction Show Parameter in URL

I need to Redirect to Action with a model object from another action method. It is ok but when i do this, i can see all the parameters in the URL address bar. Since it is about payment, it is not ok for me ? I can do this basicly passing ID but my model is viewmodel and there is no Key. How can i...
umki
1

votes
1

answer
27

Views

Combine two regular expression into one while validating Attribute

I have two regular expression. [RegularExpression(@".*[^ ].*", ErrorMessage ="Something")] validate string that only contains spaces(Not any other characters Ex: " ".length = 7). [RegularExpression(@"^[^[email protected]#$%&*]+$", ErrorMessage = "something")] validate string that contains [email protected]#$%&* special...
Sipun
1

votes
1

answer
307

Views

Is it possible to programmatically/dynamically determine the size of thumbnails with BackLoad and JQuery File Uploader

I'm using BackLoad and JQuery File Uploader to allow users to upload images to a website. But the thumbnails need to be different sizes for different areas of the site. For example: When uploading photos into a gallery I want thumbs to be 180x180 But when uploading Mugshots I want thumbs to be a max...
FatGit
1

votes
2

answer
598

Views

CQRS - Are Interfaces & Dependency Injection Neccessary For Read Model?

I am implementing a form of CQRS that uses a single data store but separate Query and Command models. For the command side of things I am implementing DDD including Repositories, IoC and Dependency Injection. For the Query side I am using the Finder pattern as described here. Basically, a finder is...
1

votes
2

answer
477

Views

How to display cross reference values using Entity Framework and view models

A very newbie question about MVC and Entity Framework (using data driven development). I built an EF model off an existing database. I used the EF wizard/tool in Visual Studio, pointed it to my database, and it created all the entity classes and relationships. Assume it is simple database that has...
John Lee
1

votes
1

answer
3k

Views

Uncaught ReferenceError: CustomerContract is not defined in Kendo Grid when creating new record

I'm working on an asp.net mvc project where I'm using a grid populated with a model. However, I've encountered an error when trying to create a new record in my grid, saying Uncaught ReferenceError: CustomerContract is not defined. Here's my grid and templates: #if(data != null){# #:data.Name# #}# v...
1

votes
1

answer
2.6k

Views

ASP.NET MVC Select list value using key

I am still reasonably new to C# and trying to understand list objects. I have a list object with key/value pairs in it, populated from a database (that part is working). I then want to select a value from that list, using the 'key'. From what I have read I think Linq might be the best way to do thi...
Jake
1

votes
2

answer
3.9k

Views

MVC, DropDownListFor in partialview, onchange should store selected value _somewhere_

I have a partial view that is included in my _Layout.cshtml. This partial view contains a Dropdownlist, that gets correctly filled. When the user selects a value, I want that value to be available everywhere else. So I tried to set it in my session data. That works fine. Partial view: @model MyMode...
oerkelens
1

votes
3

answer
1.2k

Views

How to create query string using Html.ActionLink

In my mvc3 razor project my I have action link @Html.ActionLink("ActionLinkName","Count","Home",new{id = 3}) This generates localhost/Home/Count/3 but I want it to create localhost/Home/Count?id=3 What changes in route should I make ?
vaibhav shah
0

votes
0

answer
53

Views

Problem bundling with local js files (third-party librairies) in Webpack 4

I'm having a hard time trying to make Webpack 4 config work. Firstly, I'm not running on a Node.js server; i'm on IIS using .Net MVC. How would I be able to load local js files in my webpack config file? Here's what my webpack.config.js looks like: const webpack = require('webpack'); const path = re...
C.O.D.E
0

votes
0

answer
3

Views

Azure web app publish with Visual Studio - not including all files

I have an MVC project being published to Azure from Visual Studio as a web app. In the solution I have a project set up as a "plugin" which is used by the web application and installed using Unity DI. Locally this works but when I publish to azure the plugin files aren't being deployed. This is h...
Heinrich
1

votes
2

answer
942

Views

Refresh page with new query string …MVC

I have an MVC 3 project where you can edit a record, or clone it. When you click on the record to edit, the url looks like this: http://localhost/Products/Edit/?Id=123 If the user clicks clone, a popup window appears asking for a new name. The user enters a name then clicks proceed. An ajax call is...
BoundForGlory
1

votes
1

answer
4.9k

Views

Handling Created and Modified Date in MVC

HI i have an MVC application which have CreatedDate and ModifiedDate feilds, 1. CreatedDate is when user create the module(any entry) 2. ModifiedDate is when user Edit the module I have following Model class namespace MyForms.Models { public class Master { public int ID { get; set; } public string...
Jot Dhaliwal
1

votes
2

answer
1.3k

Views

Open a jquery get request in a new window

I'm trying to make an ajax call to get data in a dropdownlist, call a controller and get the result in a new window. So far I have tried this: $(document).ready(function () { $('#seeTemplates').click(function () { var template = $('#templates').val(); alert("templateOpen!"); alert(template); window....
hsim
1

votes
1

answer
500

Views

ApplicationSignInManager class throws invalid cast exception

This is the code taken from the MVC5 account controller class ( this is created as a template when you set up a asp.net project) However when i pass in the following parameter to this line of code model.UserName="User1", model.password="Password1",model.RememberMe=false, shouldLockout=false var res...
Sike12
1

votes
1

answer
1.4k

Views

Object reference not set to an instance of an object in TempData

[HttpPost] public ActionResult Create(EmployeeEntry employeeentry) { if (ModelState.IsValid) { EmployeeEntry employeesales = new EmployeeEntry(); employeesales.stock_id = employeeentry.stock_id; employeesales.quantity = employeeentry.quantity; employeesales.total = employeeentry.total; employeesales...
King_Fisher
1

votes
1

answer
2.4k

Views

Angular ng If not working with razor syntax

I am using Angular Js with Razor. @{ var pageMode = (string) ViewBag.PageMode; } Greetings Value is in ViewBag.PageMode is "answer", still the ng if does not render. i.e "Greetings" message does not work. What am I doing wrong here... ?
Yasser
1

votes
5

answer
5.4k

Views

Rendering a JsonResult to a string in Razor

I have a server-generated object that I need to convert to a JSON object for JavaScript to consume. I prefer to render this JSON object directly into a JS variable when the view renders to prevent an additional HTTP request. This is in my controller: public virtual JsonResult GetTheThings() { retur...
Chris Barr
1

votes
1

answer
4.5k

Views

partial view refresh not working after ajax call on a button click

I have a partial view and and submitting form on a button click using ajax. After submitting I want to reload the partial view and show a success message. Ajax request is submitting correctly but I m unable to reload the partialview in the desired div with class divPartial. The partial view is loadi...
rumi
1

votes
1

answer
1.8k

Views

How to get Boostrap popover feature on an Html ActionLink in MVC?

I have a table with ActionLinks. I am trying to figure out how to wrap these so that I can display a bootstrap popover feature. Any help is appreciated! Here is what I have before trying to make any changes to allow for Bootstrap-Popover feature: Group Name Description Last Change
Tim
1

votes
1

answer
1.9k

Views

X509Certificate2 Access to a Private key into a security token

I must use a certificate stored in a Security token. I can access it from the windows certificate store, but the device has a password, so is displayed a pop-up with a input field. This is the code who I use for load the certificate: static X509Certificate2 BuscarCertificado (StoreLocation location...
Maske
1

votes
5

answer
1.5k

Views

Load Kendo Grid in Kendo Window

I want to open Kendo Grid in Kendo Window. My Kendo window code is like this. $("#Dialog").kendoWindow({ title: "Add", modal: true }); var dialog = $("#Dialog").data("kendoWindow"); dialog.center().open(); I want to open kendo grid in window. I am not passing any values t...
Chatra
1

votes
2

answer
22.1k

Views

How to use Dropdown list in cshtml

How to use dropdown list in cshtml? I am using below code ,Now it looks like general HTML but problem is not apply the bootstrap styles. @{ List listItems = new List(); listItems.Add(new SelectListItem { Text = "AtlantaPort", Value = "AtlantaPort" }); listItems.Add(new SelectListItem { Text = "NewJ...
Naresh Raju
1

votes
1

answer
1.5k

Views

Send listboxfor to controller

I have a form in my view that contains a listbox. The user adds values to the listbox. When the user pushes the 'submit' button I want all the values in the listbox to be placed in my models property that is a List. Here is the Listbox in my view: @Html.ListBoxFor(m => m.Ingredients, new List(), new...
1

votes
2

answer
70

Views

Routing: in AngularJS or .NET MVC?

We are starting a major upgrade of a large WebForms application. The logic will be split between AngularJS on the front end and .NET MVC on the back end. What are the criteria about where to put routing? I can put it in RouteConfig.cs on the server and have .NET to be responsible for routing; or I c...
Felix

View additional questions