asp.net-mvc

mvc gridview with code

how to get a gridview in model view control,how to edit,delete the gridview with source code ...

throwing/returning a 404 actionresult or exception in Asp.net MVC and letting IIS handle it

Howdy, how do I throw a 404 or FileNotFound exception/result from my action and let IIS use my customErrors config section to show the 404 page? I've defined my customErrors like so <customErrors mode="On" defaultRedirect="/trouble"> <error statusCode="404" redirect="/notfound" /> </customErrors> My first attempt at an actionResul...

howt to get the error message from model state

Im using modelstate.Adderror("test","test message") And how can i get this modelstate value in controller itself. Like I need to get the error message of "test" in the controller. ...

Why doesnt browser show favicon after deployment

Hi, I have a asp.net mvc web application an it uses some favicon.ico. Now when I move it to IIS 7, as an application, the favicon stops being presented even when I try to enter the full address to the favicon. The icon is still there; the full address works in the browser to find the icon alone, but not within the applications master pag...

pass dictionary to controller asp.net mvc

I am wanting to pass a dictionary of type <int,int> to my controller via an Ajax post. The main reason here is the post may have between 1-3 key value pairs here (none of these values are known at compile time) and in the future it may go up to 5. Also in the post I have to pass in some other data, such as Id and name, which all works a...

Ajax.BeginForm show loadingElementId when OnBegin return false

Hello I'm having the same problem from this post: http://stackoverflow.com/questions/1164251/ajax-beginform-not-hiding-loading-element-when-onbegin-fails but I have not found how to solve it yet. Basically when I use Ajax.BeginForm with a OnBegin function and this function returns false, the loading elementID is still shown and it nev...

dropdown problem

I got this line of code: <%=Html.DropDownList("Status",(SelectListItem[])ViewData["statusList"], new {@style = "width: 190px"})%> The dropdown is always populated with the data from ViewData which is good but i want to be selected the value corresponding to the Model.Status property. What am i doing wrong? ...

ASP.NET MVC 1 or MVC 2

I recently recieved the ASP.NET MVC 1.0 Professional book by Wrox, and in the intervening time, I found out that ASP.NET MVC 2.0 is being released soon. Questions Should I MVC 2.0? Are there any resources specifically for MVC 2.0? Should I learn MVC 1 and then unlearn concepts and then learn MVC 2? ...

State management in ASP.NET MVC

I have built an ASP.NET MVC app some time ago, and after a few maintenance cycles am wondering whether I took the best approach to state management. Everything works, but I get the feeling there is a better way. The site is based on a search functionality that has quite a few options. A user starts using the site by filling in a numbe...

Having trouble uploading files in ASP.NET MVC

I can see there are plenty of questions and resources about this but I just cant seem to see what I am doing wrong. HTML Snippet <form method="post" action="<%=Url.Action("Create", "Image") %>" enctype="mulitipart/form-data"> <input type="file" name="ImageFile" id="ImageFile" /> And here is the Controller code, none of the Console.W...

ASP.Net MVC - Generate an ActionLink from code behind?

I have a number of permissions, and based on a set of conditions these permission determine if a user can see certain features. I have written a helper function for this as the logic in the view became quite extensive. Essentially I'm looking for a function the same as Html.ActionLink that I can access from a class file (Ideally if I c...

Cookieless sessions and cross-site form posts

Here's the situation... Site 1) ASP.NET MVC application for customers to login, view and pay bills, etc. This site is using cookieless ASP sessions to allow multiple sessions to run in tabbed browsers. Site 2) Corporate web site with standard static content. This will have a small form at the top of each page with a username/pass...

MVC2: Can't convert String to ExtensionDataObject (without knowing I wanted to)

I'm getting the following InvalidOperationException: The parameter conversion from type 'System.String' to type 'System.Runtime.Serialization.ExtensionDataObject' failed because no type converter can convert between these types. In a Post action on my ASP.Net MVC2 page, but I'm really not sure what it's referring to. I'm using data an...

ASP.Net MVC DisplayFormat

In my model I have the following DataAnnotations on one of my properties [Required(ErrorMessage = "*")] [DisplayFormat(DataFormatString = "{0:d}")] [DataType(DataType.Date)] public DateTime Birthdate { get; set; } The required annotation works great, I added the other 2 to try and remove the time. It gets bound to an input in the view...

"Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Validation" exception

I am currently getting the following exception while trying to use the Enterprise Library Validation Application Block: An error occurred creating the configuration section handler for validation: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856a...

jquery Ajax call - data parameters are not being passed to MVC Controller action

I'm passing two string parameters from a jQuery ajax call to an MVC controller method, expecting a json response back. I can see that the parameters are populated on the client side but the matching parameters on the server side are null. Here is the javascript: $.ajax({ type: "POST", contentType: "application/json; charset=utf-8",...

Changing ASP.NET MVC default folder structure

Is it possible to change around the folder organization to the following and still have MVC work. P1 Controllers Models Views P2 Controllers Models Views etc.. ...

Public resources, spark & conflict

Using this to generate my resources. Problem is, spark dies when tries to generate dynamic views because there is app_globalresources.dll and myapp.dll somewhere there - deep into temp jungles. .spark(9,36): error CS0433: The type 'Resources.Account' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET File...

How do you get the area of the current request when using MVC 2 RC?

I was using MVC 1.0 RTM, and the Haack solution for Areas I just recently moved to MVC2 RC and I'm using single project areas with my controllers in separate assemblies. My problem is that in the MVC 1 solution I ALWAYS had "area" in my RouteData.Values collection, in MVC2 RC it doesn't exist. Do you know how to get this in MVC2 RC? Th...

simple filter I can add to my controller actions that check authentication

some actions shouldn't be run unless the user is logged in. I just want to do something like: [MustBeLoggedIn] public ActionResult Blah() { } is that hard? ...