asp.net-mvc

In Asp.net MVC project is it possible to add a test project later?

Does anyobody can explain me, how to add a test project to the asp.net MVC project after I created them without it. I'm using ASp.net MVC 2 beta on VS2008 Dotnetframework 3.5 Thanks in advance Gabriel ...

Populating grid and drop down list in Empty Views

Hi, Can anyone please tell me about how to populate grids and dropdown lists on a view? To clear the requirement - I have a simple controller which has a Fill() action. The Fill View is unbounded empty view. I want to have a dropdown and a grid on this view. These controls will contain some values from table which present in the databas...

Event calendar in MVC Application?

I want to create a event calendar in my mvc application please tell me from where shall I start doing that.Any useful resource ...

ASP.NET MVC & Windsor.Castle: working with HttpContext-dependent services

I have several dependency injection services which are dependent on stuff like HTTP context. Right now I'm configuring them as singletons the Windsor container in the Application_Start handler, which is obviously a problem for such services. What is the best way to handle this? I'm considering making them transient and then releasing th...

don't flush the Session after an exception occurs - NHibernate

I am developing a ASP.NET MVC web app under .NET 3.5, NHibernate and hosted on Windows Azure. When, the webapp is run from the local development fabric it works fine. Yet, when I move it to Windows Azure, every insert performed from the MVC web role ends up with the exception listed below. Any idea what's wrong with my NHibernate logic...

asp.net MVC return View - add variable in viewpath

i have different different pages which i want to call from one controller action here is what i've done public class TemplatesController : Controller { public ActionResult Select(int id) { return View("Temp"+(id)); } } i have different view pages like Temp1, Temp2, Temp3,..etc... the id is fetched proper...

ASP.NET MVC Passing Lists to RouteData QueryString

The recommended approach for passing lists of values as a QueryString is www.site.com/search?value=1&value=2&value=3&value=4 ASP.NET handles this well: string value = QueryString.Get("value"); // returns "1,2,3,4" But I can't figure out a way of passing these values by into RouteData. The obvious approach would be to add int[] v...

ASP .NET MVC; return HTML along with JavaScript

I have a partial view which renders a table. On page load, I am using JQuery to perform Zebra Stripping on it. Whenever ajax refreshes the table, DOM elements are updated, but since JQuery code to do the Zebra Stripping is not executed; table looks ugly. I have tried adding Javascript in my partial view if( Request.IsAjaxRequ...

URL-encode parameters in ActionLink?

Hi, I have the following route registered; routes.MapRoute( "LocationsByArea", "Locations/{system}/{storage}/{area}", new { controller = "StorageLocation", action = "Index" }, null ); ...and the following code in my...

RenderAction in ASP.NET MVC does not send RequestContext/HttpContext?

If I do this in my view <% Html.RenderAction("RenderAdminMenu", "Shared"); %> and then have this in controller action RenderAdminMenu: RouteData rd = route.GetRouteData(Url.RequestContext.HttpContext); or RouteData rd = route.GetRouteData(this.HttpContext); then RouteData returned (rd) is always null. How come? ...

Calling ASP.NET MVC Controller explicitly via AJAX

I know that I can use following piece of code to refresh a div: <%=Ajax.ActionLink( "Update", "Administration", new AjaxOptions { UpdateTargetId = "grid", LoadingElementId = "grid-wait" } ) %> But this creates a link; user will have to click on it to get the view refreshed. How can I make it automatic, i.e., like say if I want the gr...

ASP.NET MVC with jQuery

Hi, I'm currently attempting to retrieve a list of objects from my database using jQuery. I have been attempting to use getJSON but the callback is never fired. However, if I use $.post(url, data, callback) ... then it seems to fire just fine. My controller actions is thus: public ActionResult GetTemplates() { IEnumerable<Temp...

How do I handle server side validation error if I have a form running inside a jQuery UI dialog?

I have the following code in my controller after the user posts the form but if the validation fails (_applicationValidator.Validate), I normally reload the "Edit" view but in this case I want to keep the dialog open and simply show these errors inside the dialog. Controller Code: [AcceptVerbs(HttpVerbs.Post)] public ActionResult...

.net mvc pass dictionary data from view to controller

A while ago, I was trying to pass a dictionary data from my view to my controller. And I was able to do so after googling on the net(remember it was one of scott hanselman's posts). The solution I had was something like <%for(int index=0; index<Model.Count(); index++){ var property= Model.ElementAt(index);%> <input type="hidde...

MVC iframe with classic aspx

Hi there, i have a MVC application that works fine; but now i need to put on one of the views, an IFRAME whose source is an ASPX page (classic aspx page, programmed in c#) the reason of doing that is that the page is located outside of our company, i just need to consume it passing a querystring. I'm doing the following on the iframe: <...

Clearing the static file cache from client machine in ASP.NET MVC

I have an ASP.NET mvc application hosted on a server. I am continually updating my CSS and JS files for the application. After changing the files and updating the same on server, when I hit the URL for my application it runs with client cache. Is there any easy mechanism by which I can clear the cache whenever there is any change in stat...

How do I get a collection of Session State objects in ASP.NET?

How do I get the collection of all Session objects in ASP.NET? (Note that I am NOT looking for a collection of objects stored in the Session object but all of the session objects themselves.) This is for an admin page that will list all active sessions and if the user is logged in will also list the user name etc. Language: C# Framewor...

ASP.NET MVC - test the controller returning different views depending on action method logic

Hi, my controller can return different views depending on action method logic. Action method 'Create' asks service to do some validation and persistence. If validation fails, action method returns same 'Create' view. If validation and save runs OK, action method returns 'Index' view (RedirectToAction). I know that getting view name is po...

Value + Text for generated SelectList?

Hello I have a problem with a generated droplist, it shows up like this: <select id="selIntervalStartTime" name="selIntervalStartTime"><option>System.Web.Mvc.SelectListItem</option><option>System.Web.Mvc.SelectListItem</option><option>System.Web.Mvc.SelectListItem</option><option>System.Web.Mvc.SelectListItem</option></select> In my ...

access Model object in jquery

I have a Model Customers, in which i have a list property PayHistory. I need to bind the table with the PayHistory object using jquery in my ASP.NET MVC (C#) application. I am binding the table using jquery as: <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <div id="PaidDate"> ...