Click here to Skip to main content
15,885,757 members
Everything / MVC / MVC5

MVC5

MVC5

Great Reads

by raddevus
Part 1: Master the ASP.NET MVC Project Template & Technologies (Razor, jQuery, JavaScript, Bootstrap, CSS). Part 2: Build an ASP.NET MVC app which runs in the browser but feels like using a desktop app.
by Mostafa Asaduzzaman
Simple Message/Reply app using MVC 5
by Simon B.
How to localize an ASP.NET MVC application and read all text from a database while still using DataAnnotations.
by kannankeril
This article is an attempt at splitting out the controller layer to reduce its complexity and improve quality and maintainability of the resulting code.

Latest Articles

by Shaurya Servegar
How to implement Custom RouteHandler and Custom Handler in ASP.NET MVC 5
by Saineshwar Bageri
In this article, we are going to learn how to implement the best Logging libraries available in the market for an ASP.NET MVC application.
by Yogi S.
Tutorial on implementing OpenWeatherMap API in ASP.NET MVC. It will teach how to get real time weather data of any city of the world.
by Proneetkumar Pradeep Ray
JQuery Datatable (Dynamic columns) populate after Ajax JSON response via server side processing - Using EF Raw SQL query

All Articles

Sort by Score

MVC5 

22 Mar 2017 by raddevus
Part 1: Master the ASP.NET MVC Project Template & Technologies (Razor, jQuery, JavaScript, Bootstrap, CSS). Part 2: Build an ASP.NET MVC app which runs in the browser but feels like using a desktop app.
23 May 2015 by Mostafa Asaduzzaman
Simple Message/Reply app using MVC 5
13 Apr 2016 by Simon B.
How to localize an ASP.NET MVC application and read all text from a database while still using DataAnnotations.
25 Nov 2016 by kannankeril
This article is an attempt at splitting out the controller layer to reduce its complexity and improve quality and maintainability of the resulting code.
18 Jan 2017 by Bart-Jan Brouwer
.Net Core datagrid with server side paging, sorting and filtering
29 Feb 2016 by wells cheung
Privilege Control System based on MVC and WCF.
16 Aug 2018 by Proneetkumar Pradeep Ray
JQuery Datatable (Dynamic columns) populate after Ajax JSON response via server side processing - Using EF Raw SQL query
28 Dec 2015 by Dhruti90
MVC functionalities with web service with simple integration
9 Feb 2016 by Wonde Tadesse
See this SO Q/A. c# - MVC5 view drop down list - Stack Overflow[^]
29 Jun 2014 by PSK_
Unit testing the MVC controller actions which are using Global or Local resources. As this is not straight forward to Mock the static properties of the resource files.
24 Apr 2015 by Ly Nguyen - LN
How to export HTML to PDF with Bookmart and TOC using iTextSharp-LGPL.4.1.6
18 Aug 2014 by Snesh Prajapati
First check for result, then only add role. That mean change the position of UserManager.AddToRole like:var user = model.GetUser();var result = await UserManager.CreateAsync(user, model.Password);if (result.Succeeded) result = UserManager.AddToRole(user.Id, "User");You can add...
14 Dec 2015 by Animesh Datta
Hello ,As per your requirement try this below codeDateTime date= DateTime.Now; string format = "ddMMyyyhhmmsstt"; Console.WriteLine(date.ToString(format)); and O/P will be15122015063146AM
25 Dec 2015 by Tim Cadenbach
License Verification Attribute for MVC and Office-Addins
25 Feb 2016 by otark777
Some thoughts about one page angular site based on ASP.NET Web API 2 and Cassandra NOSQL database
6 Jun 2016 by Sergey Alexandrovich Kryukov
Please see my comment to the question. First of all, there is no such thing as copying classes.Please see my past answer: How to implement ICloneable for a List Class?[^].The best approach is Solution 3.—SA
12 Mar 2017 by Ehsan Sajjad
if the model in the view is representing all the courses of one student, then you can just sum the total marks and divide it by number of courses to get the average of him: AVERAGE MARKS: @(Model.Sum(x=>x.Mark)/Model.Count()) and your ViewModel is not well defined,...
28 May 2014 by CHill60
You are mixing double (dis) and decimal (Total) in your calculation so you are getting an errorQuote:Operator '*' cannot be applied to operands of type 'decimal' and 'double' This is because 0.05 is of type double. To convert it to decimal add an 'M' to the end of it like this dis = Total -...
3 Jun 2015 by Richard Deeming
A Bootstrap modal is part of the same page, so you should be able to do something like this:$('#myModal').on('hidden.bs.modal', function (e) { var value = $('#myPopupInput').val(); $('#myMainPageInput').val(value);});NB: If you only want the code to run when the "Save...
1 Dec 2015 by User 11060979
It Looks like your dt.Rows is empty, means does not contain rows. You can verify this by checking dt.Rows.Count. After confirming this, you Need to find the reason why the table does not have rows.I hope this helps.
1 Dec 2015 by Krunal Rohit
Error is pretty much self-explanatory: "there is no value at position 0" - Meaning, your datatable doesn't contain any records/rows.Workaround-if(dt.Rows.Count > 0){ if (dt.Rows[0] !=null) { // do something awesome here }}-KR
13 Dec 2015 by Brownie24
A quick and dirty way to ensure your .NET MVC forms apply Bootstrap's ".has-error" and ".has-success" classes, instead of relying on .NET's ".input-validation-error" class.
14 Jan 2016 by Wendelius
Have you already checked jQuery Calendars[^] and ASP.NET DatePicker User Control (Hijri / Gregorian) shows month and year as dropdowns[^]
24 Jan 2016 by raddevus
This article extends the 2-part article I wrote showing you how to write your own blog engine in ASP.NET MVC.
31 Jan 2016 by Richard MacCutchan
They will both be the right choice, or both be the wrong choice, or neither, or just one. This is a technical forum, and we cannot possibly advise you on a choice of career. It is up to you to decide what you want to work on.
3 Mar 2016 by Patrice T
Quote:I am trying to append More than Million record to listBox. Absolutely avoid this.There is no solution to fast add a million lines to listbox.You have to find another way that fit the needs.Think about what append when you search on facebook or google: you begin to type something...
11 May 2016 by CHill60
Use HttpRequest.UserHostAddress Property (System.Web)[^]
20 Sep 2016 by Karthik_Mahalingam
Quote:"Cannot insert explicit value for identity column in table 'table name' when IDENTITY_INSERT is set to OFF."straight forward issue.Id is an identity column, you cannot explicity insert identity value to the table directly,You will have to set the IDENTITY_INSERT to ON to insert...
19 Dec 2016 by Afzaal Ahmad Zeeshan
As mentioned in Solution, you need to upload have a file that needs to be uploaded. Archive that folder and then upload as a file. For this, you need to ask the users to archive the folders first — otherwise use an offline software to do that and upload the files to server. First method will...
8 Feb 2017 by F-ES Sitecore
You need to take time to understand the web application architecture. You can't call javascript code from your code-behind even though web forms made it look like that is what you were doing. In terms of MVC you don't have any interaction with the client via the controller, that is all done in...
13 Feb 2017 by Mike Hankey
Highlighting the current menu item in MVC using the MvcSiteMapProvider turned out to be somewhat of a challenge but with a little head scratching and several cups of coffee, this is what emerged.
23 Aug 2017 by OriginalGriff
You added it to the class, but you don't appear to have a matching column in your database. As a result, SQL cannot handle any requests you make to that column. Add the column to the DB...
7 Mar 2014 by Snesh Prajapati
Modify the following line of code: url: '/person/CheckEmail',put the ”/” in your url.
27 Sep 2014 by Gerhard_Louis
Install the Metro-UI-CSS package from nuget.Add @Styles.Render("~/Content/metro-ui/css") in the of your _Layout.cshtml view.Add @Scripts.Render("~/bundles/metro-ui") after jQuery in your _Layout.cshtml view.You will have to delete the default @Styles.Render("~/bundles/css") as well as...
2 Nov 2014 by CHill60
Have a look at the reponses to these very similar...
24 Nov 2014 by Zoltán Zörgő
Passing two lists to a view is really easy. You can use the ViewBag or you can simply create a custom or dynamic model having the two list. That's it.But the question is how you intend to traverse these two. As BillWoodruff asked, you probably have some relations between these two. And at...
3 Dec 2014 by Suraj Sahoo | Coding Passion
Dear you anyhow need to do that in the Controller(Server Side), as using javascript the row gets deleted and persists until the page is refreshed. Once refreshed the row comes back again.For that on click of delete you need to have an ajax call that would call the delete action method that...
14 Feb 2015 by Abhinav S
You can do this by using JavaScript -http://www.aspsnippets.com/Articles/Create-dynamic-textbox-using-JavaScript-in-ASP.Net.aspx[^]This can also be done via code behind -Adding Controls to an ASP.NET form Dynamically[^]C#.Net - Dynamically create textbox in asp.net [^]
11 Apr 2015 by Abhinav S
If you are using identity framework, password reset is not difficult to build.Some examples -Create a secure ASP.NET MVC 5 web app with log in, email confirmation and password reset [^]Implementing custom password policy using ASP.NET Identity[^]There is no hard and fast rule that you...
29 May 2015 by user8x86
I have a table in database with some columns are: [id], [title], [data]I have created a page to allow user posting new thread. Example: If I post a new thread with the title is: "Here is my title". After submitting, the title will be converted to a link
29 May 2015 by Mostafa Asaduzzaman
Define the function in .Layout.cshtml $(document).ready(function () { $('[data-action=navigate]').on('click', function (e) { e.preventDefault(); var url = $(this).attr('data-action-target'); var params =...
5 Jun 2015 by Sergey Alexandrovich Kryukov
You did not really point out the line of code there the exception is used. The method declaration is not a point in the runtime code, not the instruction where the instruction pointer could point to.Not to worry. This is one of the very easiest cases to detect and fix. It simply means that...
8 Oct 2015 by Palash Mondal_
Please refer: Dynamically creating rows of textboxes[^]Hope this helps you getting started!
21 Dec 2015 by CHill60
Add a reference to System.Data.Entity.dll in the Framework references
21 Jan 2016 by Dave Kreskowiak
This appears to be ASP.NET code which runs entirely server side. If you're expecting to get a full file path sent by the client it's not going to happen. The server will not get access to, nor should it ever care about, what path the file came from on the client.
28 Jan 2016 by Nathan Minier
You're looking at the difference between Authentication and Authorization. What you're looking for is two things, first off using a Role Provider, and secondly using the AuthorizeAttribute.The MS guidance on role Providers is here:Implementing a Role Provider[^]There is an article on...
31 Jan 2016 by ridoy
Well, the first thing is: This forum is specialized for posting programming related questions, not career oriented suggestions. You can try The Lounge - CodeProject[^] for your query.Now,the point is about your choice and likinigs. You need to choose either web or mobile. Thats definitely...
4 Feb 2016 by Dave Kreskowiak
I seriously suggest picking up a book on MVC4 or above and EntityFramework Code First and working through them. You're not going to learn this stuff by constantly asking questions in forums.No, you don't normally put the database access code in the class objects. You normally put that code...
20 Feb 2016 by Richard Deeming
You need to pass a Table Valued Parameter to your stored procedure using Entity Framework. (It doesn't matter that you're using ASP.NET MVC; Entity Framework and Table Valued Parameter are the key things to search on.)Those search parameters will lead you to the solution:Using Table...
4 Mar 2016 by Afzaal Ahmad Zeeshan
Quote:does not exist in the current contextThis error means that the identifier that you are using does not exist in the current source file. It doesn't refer to any variable, function, class, or any other thing that compiler doesn't take as a keyword. You need to check if a function is...
8 Mar 2016 by otark777
Some thoughts about one page Angular site based on ASP.NET Web API 2 and Cassandra NOSQL database
30 Mar 2016 by Karthik_Mahalingam
Please add bootstrap.js reference to your code.cdn link
4 Apr 2016 by Richard Deeming
By adding data-toggle="tab" to your list items, you've told Bootstrap that the items should switch between tabs already loaded in the current page. It will prevent the browser from navigating to the URL specified by the nested links.Remove data-toggle="tab", and your links will work.
15 Apr 2016 by Richard Deeming
Which is better: a speedboat, or a Ferrari? *Without knowing the intricate details of your project, or your team's experience, capabilities and preferences, there's no way we can tell you which technology is "better". They're both pretty good, and both perfectly usable in ASP.NET MVC....
29 Apr 2016 by F-ES Sitecore
Google "asp.net angularjs mvc", there are hundreds of tutorials that show the basics and how to get started. If you don't understand any of them you won't understand anything anyone here has to say either.
29 Apr 2016 by pt1401
If I understand your question correctly, the only answer that comes to mind is the obvious one: You need to change all calls that use the vendor A API into equivalent calls using vendor's B API.You'd probably want to code an intermediate abstraction/facade.
29 Apr 2016 by Dave Kreskowiak
You're not going to find an answer to this question.The only answer is to rewrite all of the code that handles the calls to the A API and convert them to calls to the B API.We have no idea how much work that's going to be for you because we didn't the code.If you abstracted all the...
4 May 2016 by Richard Deeming
Your jQuery event handler is making an unconditional post, without validating the form first.Try validating the form at the start of the handler:$('#loginButton').click(function () { var $form = $('form'); $form.validate(); if (!$form.valid()){ return false; } ...
9 May 2016 by Karthik_Mahalingam
customize it based on your need using css[^] function showbaloon(elem) { elem.style.display = "block"; } function hidebaloon(elem) { ...
11 May 2016 by F-ES Sitecore
That's completely the wrong way of doing MVC. Your controller passes data to the view and it is up to the view to decide how that data is rendered, you don't generate html in your controller as that completely breaks the paradigm.So create a data model that represents your data (like a list...
26 May 2016 by Karthik_Mahalingam
You are getting the error because ad1file object is null.In order get the files from the Form, you will have to add enctype="multipart/form-data[^] attribute @using (Ajax.BeginForm("submitSchlAd1", "Home", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "error" }, new { @enctype =...
2 Jun 2016 by George Jonsson
It is possible that someone on this forum has used Winnovative software, but I would think you have a better chance if you go to their support site and mail them your question.Contact Winnovative Software Solutions[^]And first check their code samples see if there is something you...
4 Jul 2016 by Kornfeld Eliyahu Peter
There is no built-in support for that...The only option I know of is to change the menu from the columnMenuInit event of the grid...Configuration, methods and events of Kendo UI Grid[^]UPDATEWhile all I wrote is right - based on the official documentation, there is a - totally...
11 Jul 2016 by F-ES Sitecore
Your .net code runs on the server so the notepad opens on the server, it only worked on your local machine as your local machine was both server and client but once you deploy to a remote server the notepad still runs on there but as you are no longer the client of that machine you don't see...
20 Jul 2016 by Shmuel Zang
You can add the link's HTML to your string and, display it using the Html.Raw method. Something like:@{ string msg1 = "My Text My link."; @Html.Raw(msg1)}
22 Jul 2016 by Patrice T
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.The debugger allow you to follow the execution line by line, inspect variables and you will see that there...
27 Jul 2016 by Richard Deeming
Assuming you're using Bootstrap[^], the data-target attribute needs to be the ID of the modal dialog element. You can't use a generic jQuery selector, as that could match multiple elements.Departments
11 Aug 2016 by Richard Deeming
Try using the ternary operator[^]:
30 Aug 2016 by Maciej Los
My advice: forget about StringWriter[^].You've got 2 options. Depending on method used to manipulate data, you can use :XmlWriter Class (System.Xml)[^]XmlSerialization[^] or even better DataContractSerialization[^].But, you've mentioned that:Abrar Kazi[^] wrote: I am...
30 Sep 2016 by Ehsan Sajjad
You cannot have multiple jquery library files added on the page, which is happening right now, so you need to exclude one of the file which are right now there...
19 Oct 2016 by Priya-Systematix
Hi Gopal,You can create id of particular column. For eg.: you can create id of token number and apply css on particular column using jquery or javascript:$(document).ready(function()) { function blinker() { $('#blink_token').fadeOut(500).fadeIn(500, blink);} setInterval(blinker,...
14 Feb 2017 by Karthik_Mahalingam
I hope you are looking for Intranet Site Using ASP.NET MVC , Windows Authentication[^] string userid = HttpContext.User.Identity.Name; // use this to get the client userid
16 Feb 2017 by Garth J Lancaster
well, first off, the exception actually says there's something wrong with your sql - do you have a column 'Id' for example - what happens if you remove the 'order by...' clause ?secondly, thats a horrible way to write SQL statements - you should use parameterised queries, along the lines of...
10 Mar 2017 by Karthik_Mahalingam
try this $(function () { $('.invoice-row').click(function () { var $nextRow = $(this).closest('tr').next('tr'); $nextRow.toggle(); }); });
22 Apr 2017 by Karthik_Mahalingam
try alert($scope.Cheque[0].status)
30 May 2017 by OriginalGriff
You are getting stuck on pretty basic stuff - and "giving you the answers" to these won't help you for next time as there is absolutely no guarantee that even similar questions will be asked. And what that means is that you are woefully underprepared to do the job you are interviewing for, and...
26 Jun 2017 by David_Wimbley
Your issue is with the how model binding in MVC handles complex objects for use in the HTML helpers which is what you have going on in your view. Since you didn't post your model, I am guessing your model looks something like public class CountryLanguageModel { public CountryLanguage...
14 Nov 2017 by jgauffin
Save time and effort with the help of codeRR, which finds and analyses errors for you, improving code quality along the way.
2 Apr 2018 by vijay vettri
Web application with MVC ->Currently I have a database with customer data and product details. The application has been using in only one country. Now going to globally use the web application. But the customers doesn't want their customer data leave out of their country. For example if we are...
13 Aug 2018 by F-ES Sitecore
When you use "new { ... }" syntax you're creating what's known as an anonymous type, look on at like a temporary type or a type created on-the-fly. Anonymous types can only be used inside the function they are created in, so you can't pass that result to a View. If you want a reduced number of...
22 Aug 2018 by Vincent Maverick Durano
That's because you use the keyword return before trans.Commit(). That line will never be called. What you can do is something like this: var result = await _dbContext.SaveChangesAsync(); trans.Commit(); if(result > 0) return true; return false;
25 Sep 2018 by summiya1
If you are new to MVC you can try first the scaffolding to check hows scenarios are linked and working. You need to follow different tutorial. google google google. The best way to use model to pass data on beginner level. Please check following links Using Model to pass data to View in...
31 Jan 2019 by Dave Kreskowiak
In your connection strings, you're using "Integrate Security=true". Do you know what that means? That means whatever account is running your code is the account that is used to attempt to login to SQL Server. If that account doesn't have permissions to login to the server, the login is going to...
15 Feb 2019 by OriginalGriff
Do not do that! Never try to "Pre-allocate" ID numbers, that leads to subtle and intermittent bugs in production when you have multiple users accessing the DB which are very hard to track down, and even harder to untangle the data. Look at using a DB IDENTITY field instead - the DB will manage...
19 Feb 2019 by F-ES Sitecore
$('#iCnt') The above means an element with a literal id of "iCnt", eg; What you really want is the value of the iCnt variable, not "iCnt" as literal text $('#' + iCnt) That will construct a param like '#2' or '#3' depending on what is in iCnt.
22 Feb 2019 by Afzaal Ahmad Zeeshan
Your question itself has the answer, your task has not yet been evaluated—Result = "{Not yet computed}. You need to give it more time, and check the result later. This time won't be known to you, since it is undefined amount of time. That is because in the synchronous code you need to wait for...
24 Feb 2019 by OriginalGriff
Never accept code from unknown website for anything to do with real money: you don't know the source, you don't know what the code does, and you would be held personally responsible for any losses incurred by using such code negligently - and using random code would most certainly be seen as...
31 Aug 2019 by Thomas Daniels
I can't see the code you use to render the image, but I'm guessing that you create an img tag with as src the API response. D:\Images1\1.jpg is not a file path that will be recognized by your browser. You'll have to use this: file:///D:/Images1/1.jpg But note that if anyone accesses your MVC...
26 Nov 2019 by Afzaal Ahmad Zeeshan
What you are looking for is to be done on the runtime, and these attributed at mapped at compile-time. You will not be able to modify them after your app has been built. One way to solve this would be to use a dynamic route and then process the actual URI on runtime and execute the...
20 Dec 2019 by Richard Deeming
You can't nest forms in HTML. Change the target of your outer form, and remove the nested form. Also, remove the onClick method, which simply throws away the form and makes a GET request for the SaveData action. @using (Html.BeginForm("SaveData", "Access")) { @Html.AntiForgeryToken() ...
29 Jan 2020 by Richard Deeming
That article is dangerously wrong. You don't need to create a shared folder to host an application in IIS. You just need to make sure the IIS_IUSRS group has read permissions on the folder. And setting your application pool to run as LocalSystem is extremely dangerous. The slightest mistake...
31 Jan 2020 by F-ES Sitecore
When the msg has finished the fadeOut animation it is hidden, and there isn't anything in your code to show it again, so it remains hidden. "fadeOut" just animates from the current visibility to not shown, but if it is already not shown then it has nothing to do, it remains not shown. The...
26 Jun 2020 by OriginalGriff
Quote: what is the languages used in creating Code Project? A bunch of 'em: English, Australian, and French. PLus the usual culprits: C#, Javascript, a huge pile of SQL, and some JS frameworks, I believe. Quote: best choice of languages to...
30 Sep 2020 by F-ES Sitecore
I changed your action signature to this public ActionResult Create(EmployeeDAL OBJ, string Details, List Details2) because "Details" is a single string rather than an array. You need to create a single JSON object with a property that...
22 Jun 2021 by Richard Deeming
You've tagged this question as Entity Framework. If you're executing a query against the database, you'll need to use the appropriate function. For EF 6.2 or later, use DbFunctions.Like: var result = Set.Where(u =>...
12 Jul 2021 by Richard Deeming
Quote: @Scripts.Render("~/bundles/bootstrap") Look at your BundleConfig.cs file - the bundles you have registered are: "~/bundles/jquery" "~/bundles/jqueryval" "~/bundles/modernizr" "~/bundles/Scripts" "~/Content/css" There is no...
22 Jul 2022 by Richard Deeming
A GET request to /Admin/PageParameters/ matches both your Index and OperationProgress actions. You need to change either the method or the route for the OperationProgress action. For example, if you add: [HttpGet("[action]") public...
8 Feb 2023 by Dave Kreskowiak
It's not the call to .Count that's slowing it down. You've got two lines that appear to be loading entire tables, users and Services, then you iterate over the both both tables, the Services table every single time you look at the next user in...
13 Jun 2023 by Graeme_Grant
It is unusual to see a success and error result returned using the same property name in a JSON result. This does not mean that it can not be handled. You have tagged your question with ASP.NET5, so I am going to focus on a .Net 5.0+ solution,...
2 Feb 2023 by Dave Kreskowiak
First, storing images in the database as anything other than binary is just going to make the image data quite a bit larger than if you just stored the bytes in a binary field, especially using base-64 encoding. Next, wrapping all that in a json...