asp.net-mvc

Where are the latest ASP.NET MVC bits?

Are the latest bits for MVC the Preview 5 release? I've been out of the loop for a while and just wanted to make sure I had the latest and greatest. ...

ASP.NET Controller Base Class User.Identity.Name

Hi folks As described in this post, I created an abstract base controller class in order to be able to pass data from a controller to master.page. In this case, I want to lookup a user in my db, querying for User.Identity.Name (only if he is logged in). However, I noticed that in this abstract base class the User property is always nul...

MVC view page throws error when button click twice from view

I have a View page which displays a dropdownlist and search button..when i click the search button it renders the data..even when i debug i can go to the action in controller..but when i press the button second time it throws this error anbd doesnt allow me to debug..i set breakpoint but no luck..any ideas? Server Error in '/' Applicati...

How to assign Profile values?

I don't know what I am missing, but I added Profile properties in the Web.config file but cannot access Profile.Item in the code or create a new profile. ...

MVC Object Instances or Static classes?

I am confused as to when to create object instances or Static Helper classes. For example, if I call a method to update a data model and submit to database, i create an instance of the DataContext. What is the lifetime of that Datacontext and is it ok to create new instances every time there needs to be a new data updates? In my contro...

System.StackOverflowException was unhandled (MVC Model BINDING)

I started getting this error when posting the form back with Model Binder. To test the problem I reduced the postback to one string property of the model but i still get the overflow error. Can anyone suggest what would cause this? UPDATE The problem appears to be related to the property in the model that is a foreign key. If this key...

Are functional languages and programming models like MVC just the next big fad?

Of late, I've been hearing many good things about functional programming languages such as F#. Additionally [and unrelated], I'm also noticing MVC is starting to get a lot of exposure - perhaps since the introduction of Silverlight/WPF. I've never been one for jumping on a bandwagon without first doing my research - in fact it took me ...

Passing a string as an argument to a controller

I know this is probably really obvious, but I cannot figure out why I cannot pass a string argument to a controller like one would an int. e.g. //controller/action/2 public ActionResult Action(int someInt) { //somenumber != null } but when i pass a string in like this... //controller/Action/x9294kskw public ActionResult Action(strin...

Lambda ForEach() Index Position

This is somewhat asp.net MVC related only for example purposes but I was hoping to achieve something like this: new SelectList(ViewData.Model.Formats.ToList().ForEach(x => index + " - " + x.Name), "ID", "Name"); Basically trying to be smart and return "index" as a number 1 - n where n is the number of items in the list ViewData.Model....

Customizing authorization in ASP.NET MVC

My Controller class is decorated with an AuthorizeAttribute to protect the actions: [Authorize(Roles = "User Level 2")] public class BuyController : Controller { ... } Anytime an action is invoked but the user is not in at least the role "User Level 2" he is automatically redirected to the login page with a url like this: http://...

Asp.Net MVC form, with unknown parameters for Controller

I'm building a questionnaire mvc webapp, and i cant figure out how to pass an unknown number of arguments to the controller from the form. My form is something like: <% using (Html.BeginForm()) { %> <div id="Content"> <% foreach (var group in ViewData.Model.QuestionGroups) { %> <div class="Group"> <%=group.Des...

Should I html encode values in an input field?

Which should I use? <input type="hidden" name="first_name" value="<%= person.first_name %>" /> or <input type="hidden" name="first_name" value="<%= Html.Encode( person.first_name ) %>" /> ...

In LINQ-to-SQL how do I save my object back into my database?

With LINQ-to-SQL in a ASP.NET MVC website I can display objects (records) from my database table. Now I would like to create a new object and save it back to the database. In my Controller, I do this: var dataContext = new MessageDataContext(); Message message = new Message(); message.Action = "save"; message.Body = "r...

Hide Submit Button for form

I am asp.net-MVC using the BeginForm syntax in my source ciew page and I was told if you want the form to submit you have to have the submit Button at the end of the using statement. I don't want to use a Button to call the desired Action I have an Actionlink set up like so: <%=Html.ActionLink("" + CreateMore, "Create", "", new { @cla...

How can I hook into the UI rendering "engine" of ASP.NET Dynamic Data?

I have decorated my model using Metadata classes attached to my model classes via the MetadataType attribute. I have some use the Range attribute, Required attribute, etc. and some custom attributes I have created. Now I want to hook into the rendering engine (or whatever it is called) of the Dynamic Data framework and be able to chang...

Global "Loading" notification with ASP.NET MVC Ajax calls

I'm interested in providing a general "I'm making an ajax call" notification ... similar to how most of google's services have a little red loading notification when it's busy making a call. Is there a way of globally tapping into some event that I can use to show/hide that notification if there is an active call? We're not using the j...

Parsing Form Post Values From a Table in ASP.NET MVC?

Ok, I'm an MVC newbie coming from a webforms background, so please excuse any ignorance here. Here is my scenario. I've got a table consisting of a list of applications and associated permissions. Each table row consists of 3 pieces of information: a checkbox, some text describing the row, and a dropdown list allowing the user to select ...

Export HTML Table in asp.net MVC

I trying to export an HTML table named Table that is dynamically binded to ViewData.Model in C#. I have a method called export that is called based on another method's actions. so everything before that is set up.. I just don't know how to export the data to a CSV or Excel file.. So when the I step inside the Export method I don't know w...

How to get rid of validation warnings

The complete warning is Validation (): Element 'html' occurs too few times This is for a JSON view, which you might guess returns a JSON result and hence no html. ...

Where can I find ASP MVC documentation?

Could anyone can tell me where I can find full ASP.NET MVC beta documentation? ...