asp.net-mvc

How to catch exception in asp.net view rendering?

I see there is a nice [HandeError] attribute which could be applied on controller class or method. What is my options if I would like to catch and handle exceptions which ocurred during rendering? ...

ASP.Net MVC2 Custom Templates Loading via Ajax and Model Updating

I have a view model with a collection of other objects in it. public ParentViewModel { public int Id { get; set; } public string Name { get; set; } public List<ChildViewModel> Child { get; set; } } public ChildViewModel { public int Id { get; set; } public string FirstName { get; set; } } In one of my views I pas...

ASP.Net MVC Form-post and jquery View not updated

Hello, I'm using asp.net mvc with jquery. I'm trying to make a formpost and just update the ascx that making the post. I'm making the post with following code: $(document).ready(function() { $('#search-form').submit(function() { var form = $('#search-form'); var action = form.attr('action'); var serializedFo...

How can I manage Cache stored on the web server when I'm using 3 web servers?

We are working on a web application that is distributed across 3 load-balanced web servers. A lot of the data we retreive via NHibernate is stored in System.Web.Caching.Cache. System.Web.Caching.Cache does a lot to increase the responsiveness of an application, but there are a few issues that we don't exactly know how to resolve, such ...

Cannot get my html input array to serialize into a List<string> in Asp.Net mvc

I am attempting to implement a tagging system into my asp.net MVC project. When a user edits or adds a task, they can add any amount of tags they want before submitting. I am using the Jquery Tagit plugin, so when a user adds a new tag an input field is created that looks like: <input type="hidden" style="display:none;" value="tag1" n...

MVC Dynamic controls load/post different models

I have such scenario when i have to load controls dynamically. I have untyped view and a set of strong typed controls. All strong typed controls has completely different models. The questions is, how to create kind of generic post action method wich allows to get all this models on post? May be some one may suggest the more efficient w...

Getting Error "CS1026: ) expected" when trying to combing .js files using SquishIt

I'm trying to combine a couple of javascript files using the SquishIt library. I'm following the steps that are provided here but I'm getting a compilation error stating " CS1026: ) expected" when I try to load the page. The application is an ASP.NET MVC2 app. The code for the SquishIt functionality is: <%@ Import Namespace="SquishIt.F...

How to enable/Disable textbox. and also make text box blank on change of value in the drop down list

Hi Users, I am using jquery to do enable/disable operation. <script type="text/javascript"> $(document).ready(function() { $("#ddlUser").change(function() { var selectedValue = $(this)[0].value; if (selectedValue == "--Select User--") { $("#txtUserName").removeAttr...

How to pass data from a jquery dialog back to a controller's action to update the dialog

Hi, I am using asp.net MVC, and we're using the jquery dialog (http://jqueryui.com/demos/dialog/) so that while a user is creating a new order, they can look up books via this overlay, and the overlay will return the ID of the book to an action which will add it to the order. We're able to display a list of books in the overlay, but ho...

How do you set or remove generated label styles from the jQuery Validation plugin?

This is probably something simple I'm just missing from the documentation and examples, but I'm trying to remove a style from the generated label that appears when a field is invalid. This is what I'm getting for a generated label: <label style="display: inline;" class="error" generated="true" for="FirstName"> What I want is: <la...

Getting Started with Repository Pattern

I'm trying to get started with the repository pattern and ASP.NET MVC, and I can't help but believe I'm missing something. Forgive me if this is a stupid question, but it seems to me like an implementation violates DRY exponentially. For example, in my (admittedly novice) understanding in order to implement this, I would have to: Cre...

Get referring view in an Action - MVC2

This may be more of a best practice question. I have three views (create/details/edit) that all link to their own results view (createResults/detailsResults/editResults). Each results view shares a partial with a results table on it. When a user submits one of the three (c/d/e) views, should each results view have its own action, even...

Combining ASP.NET MVC and Reverse Proxy with URL Rewrite v2

I have a need to submit some data to a different host name and was hoping to utilize the reverse proxy guide found here for IIS 7.5 http://learn.iis.net/page.aspx/659/reverse-proxy-with-url-rewrite-v2-and-application-request-routing/ I have added the following code to my system.webserver entry in the site's root web.config <system.we...

EntityReference can have no more than one related object.

I have two identical controller actions and two nearly identical views (one just has a different javscript file with it). One view works just fine, but the other gets hung up on this EF error: A relationship multiplicity constraint violation occurred: An EntityReference can have no more than one related object, but the query returned mo...

ASP.NET MVC 2 Routing with additional consistent parameters (not just controller & action)

Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have to support multiple organizations and their users. I need to have something like this: http://www.example.com/org-name/user/create http://www.example.com/org-name/user/edit/1 I was having trouble getting...

How do I handle Two Submit buttons on One Form?

I have two submit buttons and one form. How do I check what submit button was selected in my jquery code? <% using (Html.BeginForm("UserInfo", "Home", FormMethod.Post, new { id = "formNext" })) { %> .... <input id="submitHome" type="submit" name="goHome" value="Home" /> <input id="submitNext" type="submit" name="getNext" value="N...

JQuery UI control defined via HTML attributes instead of JavaScript

This question comes out making use of the HTML helpers in ASP.NET MVC and jQuery. For example, if I define an extension method like the following: <:% Html.DatePickerFor(x => x.StartDate) %> I would want it to make use of the jQuery DatePicker. However, this either means I need to manually add to the header the invocation of the DateP...

How to get a lambda expression from a PropertyDescriptor

I have some code that enumerates over an object and records any errors it has based on its ValidationAttribute(s). As it finds them I wish to create a collection of a custom class named RuleViolations. The RuleViolation class looks like this: public string Message { get; set; } public LambdaExpression Property { get; set; } ...

asp.net mvc 2: Overriding client validation so i can use jquery effects?

Hi there, is there a way to override client validation so i can use jquery? Currently i am using attributes on my model, a new feature of mvc 2 Thanks in advance ...

Ajax #anchors processing with MVC

I am looking to standardize the processing of ajax #anchors at the server side, using MVC. Before a controller action is invoked I want to convert every request with ajax anchors into a request without ajax anchors, so that the controller code does not know there were anchors in the request: For example: 1) /user/profile#user/photos ...