asp.net-mvc

ASP.NET MVC: Passing several objects to the view including a validation model

I like using Models for validation <!-- ViewPage --> <%@ Page Language="C#" Inherits="ViewPage<TopicModel>" %> ... <%= Html.TextBoxFor(m => m.Title) %> ... <%= Html.TextBoxFor(m => m.Description) %> // Controller [HttpPost] public ActionResult NewTopic(TopicModel model) { // validate } It works great, but when I need to p...

How to learn C# and ASP.NET MVC at the same time?

My question is straight forward. I'm totally new to the Microsoft stack, I have experience in web programming using PHP and Django; and I'm very interested in learning ASP.NET MVC. Is there a way (tutorials, reference books.. what ever!) to learn the C# language AND ASP.NET MVC at the same time? I mean in the same introductory material (...

How to find /open file from PC

Hello all, you experts probably knowing the easyiest ways to open/find a file from asp.net mvc application. could you tell me please how to do that, if i want for example to find and upload a photo from my PC. Thanks and take care, Ragims ...

.NET MVC learning

I am a UI Designer. My key areas of expertise are in XHTML, CSS and Javascript. I don't have any experience in Server Side Programming. I've joined a new company as a UI Developer where I need to learn .NET MVC using C#. I don't know anything about ASP, C#, MVC etc. To learn these, where should I start? ...

ASP.NET MVC 404 handling and IIS7 <httpErrors>

Good day! I use strategy to handle 404 errors like this: http://stackoverflow.com/questions/3545906/error-handling-for-asp-net-mvc-2-and-iis-7-0 or this: http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404s-in-asp-net-mvc/620559#620559 In short: I handle 404 as exception in Global.asax without adding any routing ru...

uploading files in ASP.NET MVC

When I select a file and submit the file for upload, I can't get the value of the File path in my Model. In the Controller it shows as null. What am I doing wrong? View <form method="post" action="/Account/Profile" enctype="multipart/form-data"> <label>Load photo: </label> <input type="file" name="filePath" id="file" /> <in...

No client side password matching on MVC view.

I have the following (abridged) DTO for registering a new user: [PropertiesMustMatch("Password", "ConfirmPassword", ErrorMessage = "The password and confirmation password do not match.")] public class RegisterModel { //..... [DataType(DataType.Password)] public string Password { get; set; } [DataType(DataType.Password)] ...

send email asynchronously in asp.net mvc 2

Hi I need to send email in asp.net mvc 2 asynchronously after a certain action is executed. i read this thread http://stackoverflow.com/questions/461361/asp-net-mvc-framework-automatically-send-e-mail Any further help is appreciated ...

Decoding a tag in ASP.NET MVC

I'd like to know if there is an alternative for this in ASP.NET MVC: <input type="file" name="filePath" id="file" /> I would like to have it with some code sample: <%= Html.TextAreaFor(m => m.FilePath,1,32,null)%> ...

Generate xml from form inputs

i have a form in Asp.net MVC. On submitting i want to generate the xml of the input. Whats the best way of doing it? I can do it by capturing the names/id of form in Post event and can generate xml. Is there any better automated way? ...

ASP.NET MVC: Sending data to views in POST requests

I have the following code: public ActionResult Foo() { var a = "a"; return View(new FooModel { A = a}); } [HttpPost] public ActionResult Foo(....) { // I need to set all the values of the ViewModel again, not to get a null exception in the view return View(new FooModel { A =...

ASP.NET MVC 2: Where to put custom JS files?

Hi there, what is the recommended place to put .js files - not really talking about jquery etc.... but my own custom js files.. The scripts directory seems to contain ajax, jquery etc... So is this the correct place? OR would a better place be COntent? I also was doing a search and saw some arguments for placing the JS files in the V...

Sharing data between two async requests in ASP.NET MVC

I want to share data between two async requests to the server. When some session variable value is changed in the first request (the value is changed continuously) I want the updated values in the second request. How i should do this? ...

How to structure my ASP.NET MVC 2 project with Areas sensibly

I want to structure my ASP.NET MVC 2 web application sensibly using Areas. The application consists of the two main parts Website which is the default part and Dashboard which administrates the site using a CMS. (Probably, more Areas will follow later on.) How do I structure my project best? Should I ... create the Area Dashboard and ...

Multiple web forms vs jquery selectors

Hi everyone. I'm reading Steven Sanderson's book Pro ASP.NET MVC 2 Framework. In his book, he use multiple web forms on a single web page to list products from database and provide Add to cart functionality. When should I take this approach vs having single web form and using jquery selectors to add certain products to shopping cart? T...

override error message (The value 'xxx' is not valid for Age) when input incorrect data type for input field asp.net mvc

Hello everyone, I've tried to override error message when input incorrect data type in input field on HTML form. For example I have the model like this. public class Person { public string FirstName {get;set;} public int Age {get;set;} } For view, I put text input for Age to get it value. When type some string in Age text bo...

problem with static variable

I have a problem with static variable. Part of the organization of my controllers is as follows: namespace MyApp.Controllers { public class DevicesController : Controller { static int some_var = 0; [AcceptVerbs(HttpVerbs.Post)] public ActionResult SetValue(int temp){ som...

Is applying default values to properties good or bad practice?

Is it good or bad practice to apply System.ComponentModel.DefaultValue default values to my properties? What about my ViewModel properties? I ask because I'm passing a ViewModel into my Controller. This ViewModel contains properties such as OrderByColumn, SortDirection and PageSize. When the page first loads, these need to be set to som...

MVCContrib Grid and nun-nullable parameter

I'm using the MVCContrib Grid. My controller action accepts 3 parameters, the sortoptions and paging parameter for the grid, and a ResourceID parameter, that specifies which resource you want to view bids for. When i click on the links i get the following error The parameters dictionary contains a null entry for parameter 'Resource...

JQuery UI button triggering "potentially dangerous Request.Form value" error in IE

I have begin testing my application with IE and have found that buttons that are styled using JQuery UI button are posting their entire content to the server. This means that they post a span with the text inside it. This triggers a "A potentially dangerous Request.Form value was detected from the client" error in ASP.Net. This does not ...