Click here to Skip to main content
15,884,629 members
Everything / MVC / MVC3

MVC3

MVC3

Great Reads

by Sunasara Imdadhusen
MVC Logging series
by Amey K Bhatkar
How to create TreeView in MVC
by Yogesh Kumar Tyagi
Using this tip, we easily create Thumbnail of “txt, doc, docx, xls, xlsx, ppt, pptx, rtf” files in ASP.NET MVC
by Monjurul Habib
How to add namespaces for Razor pages

Latest Articles

by Stas Wolski
This article describes how to implement a meeting room booking system in an ASP.NET MVC project with dhtmlxScheduler.
by Muhammad Albedewy
Validate Anti-Forgery in 6 easy steps
by LKC05
ASP.NET MVC vs Webforms
by NavnathKale
Extending AngularJS with the help of TypeScript to make it even sweeter

All Articles

Sort by Score

MVC3 

6 Aug 2011 by Sunasara Imdadhusen
MVC Logging series
15 Dec 2013 by Amey K Bhatkar
How to create TreeView in MVC
12 Mar 2014 by Yogesh Kumar Tyagi
Using this tip, we easily create Thumbnail of “txt, doc, docx, xls, xlsx, ppt, pptx, rtf” files in ASP.NET MVC
18 Sep 2011 by Monjurul Habib
How to add namespaces for Razor pages
19 Jul 2013 by Mikhail-T
How to convert string to text file and return it back to user as a result of a controller action
10 Nov 2014 by Dirk_Strauss
Securing Your .NET Applications – A Summary Review Of Visual Guard
10 Jun 2012 by Wonde Tadesse
Assuming that your Address class contains ID ,City ... attribute, the code below will explain to you how to bind DropDownList easily in Asp.NET MVC application.1. In Model folder define the Address and Address Collection class, public class Address{ public int ID{get;set}; public...
3 Apr 2013 by Nithesh AN
Printing an RDLC file in ASP.NET MVC3 automatically by converting into PDF and using Acrobat Reader.
28 Jul 2012 by Volynsky Alex
Please look here :http://old.nabble.com/WebKit-Browser-plugin-demo-td19624494.html[^]https://developer.apple.com/library/mac/#documentation/InternetWeb/Conceptual/WebKit_PluginProgTopic/Concepts/AboutPlugins.html[^]How do I develop a plug-in with...
15 May 2013 by Volynsky Alex
Follow these steps to generate an actual report from your web application:* Create a controller that derives from PdfViewController.* Create a view that generates the HTML which should be translated to a PDF report.* Create an action on a controller which calls the ViewPDF method on the...
8 Aug 2013 by Antariksh Verma
Hi ,After doing lot of R&D in Kendo UI i got that if we want sorting ,filtering and paging on client side we have to add .ServerOperation(false) so that all functionality like Sorting and filtering works on client side.
20 Aug 2014 by Yogesh Kumar Tyagi
go through the below...
22 Nov 2015 by Anil Sharma1983
Internet Explorer 8/9 jsonresult method treats response as downloadable json result
10 Dec 2011 by R. Giskard Reventlov
This[^] is an excellent article on the pros and cons of each: read it through for some real insight.The bottom line is that neither is better than the other... they are just different and you need to pick the one which best suits both your way of working and the project at hand.
10 Dec 2011 by Monjurul Habib
Another good link:Comparing apples with really old apples :)
7 Mar 2012 by Dylan Morley
NInject will allow you to create your solution using Inversion of Control (Ioc) and Dependency Injection (DI)This is quite a large subject for a quick answer, you'll need to have a read to understand the conceptsThis should get you started...1) A similar question to yours on stack...
24 May 2012 by sunandandutt
drop.cshtml Code@{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; var listItems = new List(); listItems.Add(new SelectListItem { Text = String.Empty, Value = String.Empty }); foreach (var name in ViewBag.Names) { ...
14 Jun 2012 by Sandeep Mewara
I just think, posting such issues about a 3rd party control at telerik Forum would be more useful.Here:TELERIK Forum[^]Try looking here: Telerik RadGrid Forum[^]Posting here is fine but it might be already discussed there!I had found that specific questions related to 3rd party is...
17 Jul 2012 by Prasad_Kulkarni
Refer:ASP.NE...
18 Jul 2012 by StianSandberg
Linq generates sql -query.. That means you cant use functions in you'r queryable. And since SQL server isn't case sensitive you have to do this in a slightly other way:var result = from userlist in context.UserMasters where userlist.UserName.Equals(username)// Maybe...
23 Jul 2012 by PratapReddyP
Isn't this different from Google home page. Yes it is. This is my custom MVC Razor search page, which i have created with full features of Asynchronous data retrieval, displaying Page Preview
11 Oct 2012 by Sergey Alexandrovich Kryukov
You need to find some service which provides the ZIP code lookup. As I can see from your profile, you are in U.S., right? So, it could be like this one:http://www.zip-codes.com/search.asp[^].It would be more convenient to get a service with is provided as a Web service. Here is...
12 Dec 2012 by Jameel VM
I will explain a Nice exception handling mechanism in ASP.NET MVC. Whenever the exception generate it automatically redirect to the corresponding error page that i have mentioned at end of this comment.Please Create a class and paste the below code in that class. using System.Web;using...
3 Jan 2013 by Sheikh Muhammad Haris
I have found something here toohttp://stackoverflow.com/questions/14003353/view-in-browser-for-mvc-3-asp-net[^]
26 Sep 2013 by Jameel VM
Step 1 : Download jQuery API and jQueryTab API. You can download it from here http://jquery.com/[^](jqueryApi)http://jqueryui.com/download/[^](select your widget for the tab and download.)Step2:Create a Model class named Tab and then create two property ContentOne and ContentTwo like...
2 Jun 2014 by Sampath Lokuge
Please try is as below.Use CompareAttribute.Note:This is just a sample.Adjust it according to your app. :)public string EmailAddress {get; set;}[CompareAttribute("EmailAddress", ErrorMessage = "Emails mismatch")]public string VerifiedEmailAddress { get; set; }Check here for...
11 May 2016 by CHill60
Use HttpRequest.UserHostAddress Property (System.Web)[^]
20 Jun 2011 by Peace ON
Here is complete solution for ADD, EDIT AND DELETE file: index.cshtmljQuery(document).ready(function () { jQuery("#list").jqGrid({ url: '/TabMaster/GetGridData', datatype: 'json', mtype: 'GET', colNames: ['col ID', 'First Name',...
5 Jul 2011 by fjdiewornncalwe
Check out this list of tutorials.If you scroll down a bit or search for "Partial", you'll find what you are looking for.A couple more links...http://rachelappel.com/razor/partial-views-in-asp-net-mvc-3-w-the-razor-view-engine/[^]Google Search I used[^]
17 Jul 2011 by Abhinav S
If you can somehow load all data into the autocomplete box then using autocomplete might be better (not in terms of performance but in terms of client usability).
17 Jul 2011 by Uday P.Singh
I would suggest you to go for autocompletebox using AJAX, simply because it would be user friendly to select the item from the list of thousand items.But unfortunately, un-optimized Ajax can cause performance issues, the appearance of application vulnerability, and user confusion. It can...
17 Jul 2011 by thatraja
Here some pointsAutocomplete vs Drop-down. When to use?[^]
8 Nov 2011 by Sergey Alexandrovich Kryukov
It is not encryption. Not at all. As such — it's good to use.Forget security — using base64 is exactly the same as writing in open text. The major purpose of this encoding: encoding of binary files/streams using only ASCII characters. This is one of MIME types. See...
15 Dec 2011 by Om Prakash Pant
Data access implementation has nothing to do with MVC3 razor. It is designed to display the content in the web pages. to There are different options you can use for data access including the following: ADO.NET LINQ to SQLNHibernateEntity FrameworkSee the following link for more...
18 Jan 2012 by Namlak
string blah = string.Join(",", cities.Select(c=> c.Name));
5 Feb 2012 by zyck
try this Solutionvar yValue = "@ViewData["value"]";or var yValue = '@ViewData["value"]';Notify me if WorkingThanks
9 Feb 2012 by Winstan
MVC3 webgrid does not return rows collection, here is a tip to get several objects selected
14 Feb 2012 by Syed Salman Raza Zaidi
Make you form like this @using (Html.BeginForm("ActionResult", "Controller", FormMethod.Post, new { @enctype = "multipart/form-data" }))and in you Actionresult pass a parameter Actionresult(HttpPostedFileBase file)in this file variable,you'll get all information related to the...
12 Mar 2012 by Nelek
What do you mean?What I understand: You have written an article and when you publish it, then you can not navigate the code you have uploaded?If this is what happens, I would try to ask in the bug/suggestion forum[^]. You will probably get more help there than here. And if it is a bug, then...
14 Mar 2012 by BobJanova
You should ask yourself: is this actually a problem? As the other solutions state, you're seeing client-side cached pages, so there is no load on your server, and none of the links or forms (or AJAX scripts or anything that talks to a controller) will work, so nothing can actually be done by...
14 Mar 2012 by Prasad_Kulkarni
There are two ways to achieve your functionality.1. You can build your model with string property and add controls with html stuff you need and then render it from model in view.public class checkboxes{ public string checks{get; set;}}Then you...
14 Mar 2012 by member60
in the view add:and in the controller you can get the vale of checkbox as:public ActionResult LogOn(bool? rememberMe) { bool remember = Convert.ToBoolean(rememberMe);...}and now the bool type variable you can save in database , for this create a...
10 May 2012 by Sandeep Mewara
You use Session the same way as you do in ASP.NET Webforms.Simply use the Session object: HttpContext.Current.Session["CurrentUser"]
12 May 2012 by Wendelius
I suggest that you go through these:LINQ Query Expressions (C# Programming Guide)[^]join clause (C# Reference)[^]How to: Perform Inner Joins (C# Programming Guide)[^]How to: Perform Custom Join Operations (C# Programming Guide)[^]And a small sample: LINQ - Join Operators[^]
12 May 2012 by P.Salini
see thesehttp://www.dotnetperls.com/join[^]http://forums.asp.net/t/1799369.aspx/1[^]http://stackoverflow.com/questions/373541/how-to-do-joins-in-linq-on-multiple-fields-in-single-join[^]
15 May 2012 by Zoltán Zörgő
Use:@Html.Ra...
18 May 2012 by Stephen Hewison
Hi,You can pass a different model to your partial view.Within your main page, add the following:In your main page you'll need access to the model for the partial view. Just pass it in when you render the partial view.
21 May 2012 by Jonny Galt
I am using MVC3. I have a couple of pages which do not require authentication but these pages have querystrings which could be tampered. These pages are for info collection forms for guests which do not need to be authenticated. I am planning to encrypt these urls when sending to users and...
22 May 2012 by Prasad_Kulkarni
Please refer: Series of 10 articles.Creating an Entity Framework Data Model for an ASP.NET MVC Application (1)[^]Implementing Basic CRUD Functionality with the Entity Framework in ASP.NET MVC Application (2)[^]Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC...
23 May 2012 by Prasad_Kulkarni
Please Have a look at these for AJAX control AutoCompleteExtender:AutoComplete With DataBase and AjaxControlToolkit[^]Using Ajax AutoCompleteExtender for autosuggest[^]ASP.Net AJAX Control Toolkit AutoCompleteExtender without using Web Services[^]AutoComplete Demonstration[^]Have a...
24 May 2012 by GateKeeper22
If it was me I would just serialize the form and call the controller method with AJAX. If you do a post the query string won't be visible to the user. After the AJAX call is successful you can forward them on to the next page you want them on. I have included some example code to do use this...
12 Jun 2012 by vyas_pratik20
hi ,This blog http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx[^] will help you to fix your problem.
21 Jun 2012 by Prasad_Kulkarni
Addition to Sandeep's answer don't forget to search on CodeProject Answers[^]
18 Jul 2012 by Christian Graus
You are confused. AJAX and jQuery are not contradictions, they are two complementary things. You should use jquery to make AJAX calls. AJAX cannot show your popup, but it is the ONLY way to contact the server without refreshing your page.As someone else said, there are a number of jquery...
19 Jul 2012 by PratapReddyP
When you create a MVC3 application, the solution is created with default code which you can execute and understand the flow. above which you have great books and authors. I started the way you searched and i wrote some posts on my blog with code samples, explaining step by step.Hope this will...
5 Aug 2012 by Christian Graus
Although it seems you got your answer, I want to add, I don't think this is a great way of doing things. It looks like this library is doing some magic hookup stuff for you. MVC will create a CRUD controller for you for free, but overall, you should be writing code that uses a viewmodel,...
9 Aug 2012 by StianSandberg
Create a controller which read the imagepath from database and returns it as Image from your Controllerpublic class ImageController : Controller{ public ActionResult ShowImage(int id) { // access your database and read the filepath based on id return new...
6 Sep 2012 by Syed Salman Raza Zaidi
Use: @model IEnumerableon top of your view,as you're having IList so you'll have to specify model as IEnmumerable
16 Oct 2012 by fjdiewornncalwe
This one is pretty good. ASP.NET MVC3 Slideshow Control using jQuery and XML[^]
30 Oct 2012 by Member 9359591
htmlvar account = document.getElementById('account');var changed = document.getElementById('account_changed');changed.value = new Array(account.value.length-3).join('x') +...
6 Nov 2012 by Sandeep Mewara
I have not tried so not sure about App_Offline.htm way to handle it. Details here: App_Offline.htm [^]Following is one of the ways suggested and implemented by quite a few: Implement “Down for maintenance” page[^]. It says:You can use a catch-all route with a RouteConstraint with the IP...
6 Nov 2012 by jim lahey
You don't need to write any code, it's already been done:http://captchamvc.codeplex.com/[^]
4 Dec 2012 by OriginalGriff
See here: Sending an Email in C# with or without attachments: generic routine.[^]
22 Dec 2012 by Nick Fisher (Consultant)
You are better off handling the mouse-overs using CSS, and the image loading can be done using the 'CSS' attribute in JQuery.Try: .search { width:150px; height:150px; background:url('search.png') no-repeat center...
19 Feb 2013 by Zoltán Zörgő
$(function() { var collectParams = function(){ var params = { OccupationId:$("#Occupation").val(), NationalityId:$("#Nationality").val() }; if(params.OccupationId &&...
6 Nov 2013 by Zoltán Zörgő
There you have it: ContactUs.cshtml. Why do you think, that the engine will guess this?Either rename it to Contact.cshtml or return with the proper view: return View("ContactUs");. See: http://msdn.microsoft.com/en-us/library/dd460352(v=vs.108).aspx[^]
6 Dec 2013 by Wombaticus
reslts in milesSELECT id, ( 3959 * acos( cos( radians(YOUR_LATITUDE) ) * cos( radians( YOUR_DB_LAT_FIELD ) ) * cos( radians( YOUR_DB_LNG_FIELD )- radians(YOUR_LONGITUDE) ) + sin( radians(YOUR_LATITUDE) ) * sin( radians( YOUR_DB_LAT_FIELD ) ) ) ) AS distanceFROM YOUR_DB_TABLE HAVING...
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 [^]
4 Aug 2015 by F-ES Sitecore
Without using EF and also without ado.net? You could use ODBC libraries but you're seriously better sticking to ado.net. ado.net is the most basic .net framework for connecting to databases so you should use it, there is nothing wrong with it.If you mean without EF and just ado.net, then...
8 Oct 2015 by Palash Mondal_
Please refer: Dynamically creating rows of textboxes[^]Hope this helps you getting started!
29 Oct 2015 by F-ES Sitecore
var car = carContext.Vehicles.FirstOrDefault(x =>x.Reg == reg && x.manufacturere == "BMW")That will select the first where the reg and manufacturer match the parameters supplied.
10 Feb 2016 by F-ES Sitecore
You can't force the client to print a document without asking. Printing costs money, can you imagine how annoying it would be if every site you visited forced adverts\coupons etc to your printer?
9 May 2016 by Karthik_Mahalingam
customize it based on your need using css[^] function showbaloon(elem) { elem.style.display = "block"; } function hidebaloon(elem) { ...
17 May 2016 by F-ES Sitecore
Session["Id"] = user.Id;--id is 0 hereNothing has updated user.Id so it stays at 0. Tryuser.Id = i;Session["Id"] = user.Id;orSession["Id"] = i;
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...
26 Sep 2017 by Karthik_Mahalingam
check this emoji -button outside - JSFiddle[^]
10 Jun 2011 by dasblinkenlight
This is because OrderByColumn is just a string. It is unrelated to the values that you are sorting: expression x => OrderByColumn returns the same value for all instances of x, so it makes sense that the sort does not work.Making it work is a more interesting question: if you are good at...
10 Jun 2011 by Sunasara Imdadhusen
Here is the Excellent solution for the samehttp://landman-code.blogspot.com/2008/11/linq-to-entities-string-based-dynamic.html[^]
18 Jun 2011 by Shahriar Iqbal Chowdhury/Galib
hi,use this code below, ' style = 'float:left; visibility:' />
26 Jun 2011 by Dave Kreskowiak
You seriously want a "code sample" of something so large?? If you're new to .NET, this project is WAY over your head right now. A simple code snippet isn't going to cover everything you need for this.You've got a lot to learn about just the .NET Framework, ASP.NET, patterns and practices,...
5 Jul 2011 by K N R
Hi every one,am start to learn mvc3 partial view can you please help methanks
7 Jul 2011 by fjdiewornncalwe
Have you tried looking at the Telerik support site? Clickey[^]Specifically I found this[^] page,as well as this[^] one.
16 Jul 2011 by thatraja
Fix links for youAccess denied to c:\inetpub\wwwroot\xx. Failed to start monitoring file changes[^]PRB: "Failed to Start Monitoring Directory Changes" Error Message When You Browse to ASP.NET Page[^]
22 Aug 2011 by TheyCallMeMrJames
How do you mean does not work? As in, it's being greedy and taking other requests, or as in requests to content/whatever are not being picked up?Two things to try. First, read an overview[^] on custom routes to make sure what you're doing aligns with what routing is expecting of...
2 Sep 2011 by #realJSOP
RESX is in xml format, so yes, you can open it and parse it. PERSONALLY, I would parse it in the C# code (since the files would have to be on the server side anyway).EDIT (after your comment) ============================If you have to show the text of the file, just open it as a text...
7 Sep 2011 by Syed Salman Raza Zaidi
You could use a normal link with target="_blank" attribute:@Html.ActionLink( "Generate PDF", "GeneratePdf", "MyController", null, new { url = "some url", target = "_blank" })or if you want a button you could use javascript in separate JS...
2 Oct 2011 by jim lahey
With MVC you can render a simple HTML table in your view and use something like jQuery's DataTables plugin to provide paging, sorting etc.http://datatables.net/[^]There's a good CP article on this topic too:jQuery DataTables and ASP.NET MVC Integration - Part I[^]
4 Oct 2011 by Sunasara Imdadhusen
HiAll,I would like to use something like AutoMapper for the following code instead of manual mapping.I have two tables User and Role and both mapped with RoleID. now problem is if i am getting records from Users then it will gives me only RoleID instead of RoleName. So i tried to get...
4 Oct 2011 by Sunasara Imdadhusen
I have SOLVED this question using following solution:public IList GetUsersWithRole() { IList users = _UserRepository.GetAll(); IList userswithrol = new List(); AutoMapper.Mapper.CreateMap
8 Nov 2011 by OriginalGriff
Base64 is no an encryption mechanism - it is an data conversion mechanism. It requires no key and is completely insecure. If anyone reading your data has any idea of data communications, it is immediately readable.Instead, look at using Session information, which is stored in cookies. You...
26 Nov 2011 by amitthk
For ASP.NET MVC, HERE! is a much cooler approach:Basically, we use Ajax.ActionLink like this:The controller takes care of both the possibilities (Normal Post...
29 Nov 2011 by Alberto Biasiutti
Hi everyone,I'm developing an MVC3 application;I need a series of variables which contains necessary info regarding the specific user (and user operations) to be accessed by almost any part of my application.I came up with the solution of creating the necessary Static Classes, with...
2 Dec 2011 by Sergey Alexandrovich Kryukov
You can find one of the solutions here: http://www.matlus.com/html5-file-upload-with-progress/[^].As this is a very popular question, you can find a lot more: http://en.lmgtfy.com/?q=upload+file+with+cancel+HTML5[^].—SA
18 Dec 2011 by Abhinav S
If you date is a DateTime then its fairly easy.Just extract the Day, Month and Year as shown below.int year = dt.Year;int month = dt.Month;int day = dt.Day;You can then assign them directly to your dropdowns.Read more about this here[^].
19 Dec 2011 by K Herms
The problem is that you do not have access to overwrite the same file. To handle this you should move the file to another location after the upload. Before you move, you check if there is a file with the same name. If there is another file with the same name, you need to decide what you want to do.
19 Dec 2011 by Monjurul Habib
Read the following thread:Renaming file in C# on ServerHow can I upload a file and save it to a Stream for further preview using C#?And an article:Uploading a File (Or Files) With ASP.NET MVC
20 Dec 2011 by Ankur\m/
There are some good discussions here - Razor vs Webforms view engine for new ASP.NET MVC 3 site[^]You can find many more discussion here: razor vs aspx[^].
29 Dec 2011 by Rohit from Delhi
hi, how to pass data from one view to controller in mvc3
25 Jan 2012 by Syed Salman Raza Zaidi
Hi,I am making an application in MVC3. IO have implemented the functionality that if user type after URL his/her username then he'll be redirected to the profile pagefor eg if he types http:\localhost:4341\usernamethen he'll be redirected to...