asp.net-mvc

Is there an existing solution to AJAX timeouts with ASP.NET MVC and jQuery?

You are using ASP.NET MVC with jQuery. You make a lot of AJAX calls. You want to notify the user if they click something and the session has timed out. Does anyone have a good existing solution to this that also includes notifying the user of timeout after initiating an AJAX request? (There are known solutions for non-AJAX ASP.NET ...

ASP.NET MVC iterate through collection within collection

I have an ASP.NET MVC app in which I am iterating through a Linq result set. Each row in the result set contains a property which is an EntitySet itself. When I try to iterate through the inner result set, I get an error message: "Invalid object name EntitySetOfSubItem" when trying to load the page. How do I process this collection? <% ...

jquery $.Post doesnt change view. What do I do?

Hi all, I'm pretty new to MVC so this may seem like an obvious question, but when posting to my ActionResult, the ActionResult gets called, but the View doesn't change. What I'm doing is having a basic search page where a user can search my database and the results are returned and paginated. Here is javascript that calls that ActionR...

Is there a way to have the DefaultModelBinder ignore empty items when binding to a List<Enum>

I have a scenario where I'd like to change the behavior of the DefaultModelBinder in how it binds to a List of enums. I have an enum... public enum MyEnum { FirstVal, SecondVal, ThirdVal } and a class for a model... public class MyModel { public List<MyEnum> MyEnums { get; set; } } and the POST body is... MyEnums=&MyEnums=Thi...

Data Annotations with Entity Framework+MVC

Hi, I have a very basic entity model which I'm trying to add custom validation messages to. My metadata looks like this: namespace My.Models { [MetadataType(typeof(My.Models.ConsumerMetadata))] public partial class Consumer { } public class ConsumerMetadata { [StringLength(5)] [Required(ErrorMessage="First name is an absolu...

asp.net mvc: best way to use html.radiobutton

In a asp.net mvc form, im using a radiobutton set, to set a property. <%=Html.RadioButton("Tipo", "Pizza", CType(Model.Tipo = "Pizza", Boolean), New With {.id = "Pizza"})%> <label for="Pizza">Tipo Pizza</label> <%=Html.RadioButton("Tipo", "Barra", CType(Model.Tipo = "Barra", Boolean), New With {.id = "Barra"})%> <lab...

Debugging AJAX caching in ASP.NET MVC

Hello, I have a simple proof of concept that seems to be handling caching oddly. Here's the view: <script> $('#clickToLoad').click(function() { $.ajax({ url: "<%=ResolveUrl("~/Home/AjaxCacheTest") %>?" , dataType: 'json' ,ifModified: true ,cache: true ,success: function(sourceD...

Can footers be added to MVCContrib grids?

I'd like for my column header to also be footers using MVCContrib grid. How can I add footers? <% Html.Grid(Model).Columns(col => { col.For(c => c.sub_id).Named("Id"); col.For(c => c.name).Named("Name"); col.For(c => c.group).Named("Group"); col.For(c => c.insurance_GL).Named("Insurance").Format("{0:d}"); }).Attributes(id => "list").Re...

How to upload files from a web app into Flash Media Server correctly?

My company is building Flash video web app which features uploading. I am in charge of this project, and have some and questions before I start to plan the structure and code. We have a Windows server machine, running 2008, where we are going to host this app. We develop primarily in ASP.NET MVC using C#. We are going to put the Flash ...

In ASP.NET MVC app, simple custom HTTPModule issue

My first custom HTTP Module, baby step 1 - just getting the plumbing down. I'm not getting my string in the 200 response but it is there in 304 responses. Can anyone tell me what I'm missing? My class: namespace WebUI.Models { public class SimpleModule: IHttpModule { public void Dispose() { } publi...

Apply C# Attribute to Extension Method to Manage Extension Method Execution like an Action Filter

Hi All I have a HtmlHelper extension method that I would like to apply some logic to before execution. I suppose I'm looking for behaviour similar to Action Filters, abut I thought I could do this by applying an Attribute to a method without the need of a Filter Context. This is my extension method: [MyHelperAttribute] public static s...

Is there a way to create an ActionLink with HTML 5 Data- attributes?

HTML5 allows the use of custom attributes prefixed with the phrase "data-" which pass validation without the use of a custom DTD (more info). In Asp.Net MVC, is there any way to specify an ActionLink with a data- attribute? The typical method for adding attributes to an ActionLink is to pass in an anonymous object, with a custom proper...

Help me get this ASP.NET MVC2 RC ActionLink to work?

I could have SWORN I had this working, but somewhere along the line I apparently broke it. Maybe it was during my migration from ASP.NET MVC in VS2008 to ASP.NET MVC2 in VS2010. My ActionLink: Html.ActionLink(segment.TitleWithChapterNumber, "Index", "Read", new { bookCode = Model.Product.Id, segmentCode = segment.Index }, null) The r...

How to assign value for javascript variable from MVC asp.net controller

Again stupid question struggling to assign a value for a javascript variable from controller ? what is the proper way to assign value to a variable below line of code is failing .. Please advice var tenmp= '<%= Model.Temp%>'; ...

Request URL encoding issue in $.ajax call and Max request URL length in $.ajax as compared to Ajax.ActionLink

I am doing a simple $.ajax request: $.ajax({ type: "POST", url: "/Run/" + param1 + "/" + param2, dataType: 'html', error: function(error) { }, success: function(html) { } }); If my param2 value is like http://localhost/pub/file?val1=Some Text&val2=Some Text then encoding done using esca...

Advanced ASP Routing tutorials and examples

The one of major hurdles I seem to be having recently is getting my head around some of the more complex routing requirements for some MVC based applications I've been developing. I'm having problems finding the right set of tutorials to walk me through it to get a complete understanding. What I'd like to find is a complete set of tutor...

Problem displaying DayOfWeek in MVC 1.0

Hi, I have an ascx page which contains the following line: <%= Html.TextBox("DayOfWeek", Model.JourneyBooking.StartDate.DayOfWeek.ToString(), new { @readonly = "readonly", style = "width:90px" })%> This is inside an .ascx page and when display it inside a jQuery dialog popup the textbox shows '5' as the contents. This should show Fr...

ASP.NET MVC Forms with both AJAX and traditional POST support

I have a form that I currently enumerate with some Javascript functionality and then post it with jQuery .ajax() to a MVC controller action. I have few questions on my options if I wanted to add traditional (no-javascript) support for posting this form. 1) The thing is I have some data that is not in fields but it is just text in divs....

ASP.NET MVC: How to show value in a label from selected Drop Down List item?

Hi! I'm trying to show a value of selected Drop Down List item in a label. I managed to make this work with Web Forms but with MVC I'm totally lost. My Index looks like this: [...] <% using (Html.BeginForm()) { %> <table> <tr> <td>Processor</td> <td><%= Html.DropDownList("lstProcessor1", n...

ASP.NET MVC or ASP.NET MVC2 RC2 -> RTM

I am designing an green field application, development will start on it tomorrow as all the User Stories, etc. have been finalized. I plan on using Windows Azure, with ASP.NET MVC, I noticed that MVC 2 RC2 is about to be released but there is a lot less literature on MVC 2 compared to MVC 1. Are there substantial differences between th...