asp.net-mvc-2

Anyone using Knockoutjs with asp.net-mvc in anger?

I find it very interesting and have a prototype working based on Steve's mvc sample and another small sample from this thread. Using json.net to deserialize within the post action as I couldn't figure how to downgrade his FromJsonAttribute from .net 4 to .net 3.5, which I'm running in this case. Wanted to know if anyone had put the Kno...

MVC HttpUtility.UrlEncode

Hi All, i am attempting to use HttpUtility.UrlEncode to encode strings that ultimately are used in URLs. example /string/http://www.google.com or /string/my test string where http://www.google.com is a parameter passed to a controller. I have tried UrlEncode but it doesn't seem to work quite right my route looks like: routes.Map...

Entity relationship not reading correctly from database

I have an entity relationship setup in my mvc2 application such that each user has one role and each role can have many users. Like so: Roles Users -------- --------- RoleID-- UserID \ Name --> RoleID So a pretty basic many to one relationship enforced in the database and reflected in my entity relati...

Retrieve count of SelectList items?

Problem: I can't access the count of items in a SelectList I have an HtmlHelper method that returns a SelectList: public static SelectList FilterSelectList(this HtmlHelper helper, List<Stuff> eList, string dept) { List<Stuff> returnList = new List<Stuff>(); //Do Stuff return new SelectList(returnList, "ID", "Name"); } I then...

MVC 2, custom data annotation validation rules with jquery.validate and a validation summary

I am using a validation summary and client side validation as written about here. My problem was then that I wanted a client side validation that supported comparing the equality of 2 fields : email address and password with confirms for both. So, following Soe Tun, I was able to get my data annotations to automatically run client side...

How do I strip unnecessary information from a user friendly url before it gets to a controller action

We are trying to use custom routes in an ASP.NET MVC application to generate this url: 'http://example.com/Person/unnecessaryinfo-42'. The "unnecessaryinfo" is the name of the id which will make the URL hackable for the user. Below is the code for our route map. This works but my controller action ends up with "unnecesaryinfo-42" in the ...

Asp.Net MVC2 on qualityhosting.com

Hey Guys, did anyone deployed an Asp.Net MVC2 Application on qualityhosting.com ? I see only the Homepage but the other Controllers doesnt work. Please help me ;) Thanks!! ...

How are asp.net mvc 2 controllers instantiated?

When an asp.net application is notified of a URL, it routes it to the appropriate controller and specifically to the appropriate method. Are those controllers placed upon the stack once? Or do they get instantiated again for each request? For example, say I have a controller with a linq-to-sql class that gets instantiated in the declar...

ASP.NET MVC 2 - Using EF4 with List scaffolding

I want to show a list of game reviews for editing. This is simple to do with VS' built-in scaffolding, but I'm running into issues with handling an entity's associated EntityCollections. My controller method is currently: public ActionResult ShowReviews() { var reviews = _siteDB.Games.Include("Genre").Include("Platforms").Include(...

AreaActionLink Extension Method and namespace bug?

I wanted to add an extension method to the HtmlHelper class so that developers could generically retrieve and AreaActionLink<T> without having to add the new { area = "MyArea" } each time as well as not have to specify a Controller. This all works well and good if I specify the namespace or put the namespace of the Area Controller in the...

ASP.NET MVC - How to build custom viewmodels in C# to pass a data set to a strongly typed View?

Hi, I'm new to ASP.NET, C# and the MVC framework but have managed to build a site that works pretty well. Now I am trying to create a reporting section for the site to display a table of information on all users and just can't get my head around creating custom model classes for the joined table data. I have seen lots of examples with o...

How to handle lookups?

Hello, When I need to use a lookup I usually include the ID property in the view model class so I can use it this way in the corresponding view <%= Html.LabelFor( model => model.LookupTableID )%> <br /> <%= Html.DropDownListFor(model => model.LookupTableID, Model.LookuptableList, new {}) %> having Model.LookuptableList as a property ...

How does RedirectToRouteResult work ?

Hi, I'm currently using RedirectToRouteResult as follow: public void OnAuthorization(AuthorizationContext filterContext) { User user = filterContext.HttpContext.Session["user"] as User; if (user == null || user.Role != expectedRole) { filterContext.Result = new RedirectToRouteResult(new Route...

How Can i Render a Partial View via AJAX? (ASP.NET MVC 2)

Hi Guys, This should be relatively simple for the MVC experts out there, but i'm still learning the ropes. I have a View which is not strongly-typed, simply ViewPage<dynamic>. On this View, i have a single textbox, which is extended using jQuery's AutoComplete When the user types something into the textbox, the AutoComplete does an AJ...

ASP.NET MVC 2: Disabled TextBox for DateTime returns null

I'm encountering an irritating binding behavior for a DateTime bound to a textbox that is disabled. It always returns null. My model has a DateTime? StartDate property... I've also tried just DateTime StartDate (without the '?'). I've tried the following: Attempt #1: <%: Html.TextBoxFor(model => model.StartDate, new { @disabled="true...

Gett values of Html. controls in ASP.NET MVC with AJAX as user interact

Hey guys, I'm doing an ASP.NET MVC project just for learning...and stuck in this... I'm trying the get the value from the Html.TextBoxFor(model => model.ShortName) and show in the side www.blablabla.com/Value, it in the time of the user is typing. I tried to add the AJAX library reference on the top: <script src="../../Scripts/Microso...

Are there any non-obvious dangers in using threads in ASP.NET?

This is something of a sibling question to this programmers question. Briefly, we're looking at pushing some work that's been piggy-backing on user requests into the background "properly." The linked question has given me plenty of ideas should we go the service route, but hasn't really provided any convincing arguments as to why, exac...

Why really short timeout in ASP.NET MVC?

I have an MVC 2 application where the timeout is set to 2880 (minutes as I understand it, but even if it is seconds there's a problem): <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> Now this should then mean 48 hours, or at least 48 minutes (if the value is seconds). But the user...

another way to send data to view from controller action rather than json in "this" situation.

Hi, I am developing the full calender of jquery from some blog. I added my questions with concern this, but this question bit different. Full description of code is given here But not get satisfactory answers, so need to change the strategy . in this (in link given) code , action of controller returns the Json output and j query accepts ...

client side validation for asp.net mvc dropdown?

hi, i just wanted to know how to enable client side validations for dropdowns in asp.net mvc 2. The scenario would be that the dropdown will contain a "Select" item and the list of other items..,The user should select other items... the validation should fire when the user does not select the other items public class FacilityBulletinMod...