asp.net-mvc-2

jQuery Modal Window to Display a Table in MVC

Let me start of by saying that I am inexperienced with JavaScript. Here is what I want to do. When the user clicks "Show Details" on a row of data, they get a pop-up (modal?) window that has some data generated from another action within the MVC application. Where can I find an example of implementing something like this? Also, when a...

Asp.NET MVC 2 EF4 Dynamic Proxies

Hi. Im working on Asp.NET MVC 2 project with EF 4(POCO, Lazy disabled) and have a problem with DynamicProxies generated by EF runtime. I have strongly typed partial view for EF POCO class ie Property, but from EF context i get Property object wrapped by Dynamic Proxy Class, so after calling RenderPartial i get this error: The model it...

How to pass nullable properties from ASP.NET view to Controller?

Hi, I've been reading stackoverflow for a few years now, but this is the first time I really need to post a question as I can't seem to find a suitable answer anywhere. The thing is, I want to pass an object (a LinqToSQL entity to be precise) to my View, allow the user to add some properties, and then post it back to save it. My object...

Should an object be created in an Unhealthy State? Passing from Create controller to View

Hi What are the advantages of passing a blank object eg Client from the controller? public ActionResult Create() { Client client = new Client(); return View(client); } // // POST: /Client/Create [HttpPost] public ActionResult Create(Client clientToAdd) { ...

Cannot convert existing ASP.NET MVC 2 solution to Azure Web Role in Visual Studio 2010

Hi Everyone, I've been working on an ASP.NET MVC 2 (.NET 4.0, Visual Studio 2010) application for a while and have decided that I would like to deploy it as an Azure application. After installing the latest (June 2010) Azure tools (through Visual Studio itself) I've added a blank CloudService to my solution. Whenever I try to add a "We...

MVC Edit View, JQuery change

I have an MVC view with the following jquery. <script type="text/javascript" language="javascript"> $(document).ready(function () { $('#myinput).change(function () { alert('Changed'); }); }); </script> When I change the text in the 'myinput' box, I want the alert 'Changed' to be displayed. This wor...

How to disable Caching for certain roles in ASP.Net MVC?

I want to enable caching for all Anonymous users of my site. But for logged in users of certain roles, I want to disable caching. I am using .net4/ASP.Net MVC2. How do I achive this? ...

Property Injection in Base Controller using Ninject 2

I have the following code in my Global.aspx protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); RegisterAllControllersIn(Assembly.GetExecutingAssembly()); } protected override IKernel CreateKernel() { return new StandardKernel(new ServiceModule()); } ...

Render multiple partials from one ajax request (asp.net mvc search page)

I have a page with a search bar, facets, and a list of results. I'm trying to figure out how, if the user enters a search or selects a facet (drill down list like categories), to refresh the list of results and facets. I've messed around with templating, such as John Resig's Micro-Templating (which is very cool), but it doesn't allow m...

localize default model validation in mvc 2

[Required] [DisplayName("my date")] public DateTime? DateReg { get; set; } so if the user is going to pass in an invalid datetime value he will get this message "The value '02.07.201022' is not valid for my date." how can I translate/localize this message ? ...

ASP.NET MVC 2: How to master common update/create scenarios with popups using jQuery

I have an Index page. In the contentwrap div the overlay is rendered and popuped by jQuery. The gridcontainer shall be updated via ajax. <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2> List of Employees</h2> <br /> <div id="gridcontainer"> <% Html.Ren...

.Net MVC2 How to add error to ModelState when using custom ValidationAttribute - Solved with IDataErrorInfo

I have the following ValidationAttribute class [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class DateValidationAttribute : ValidationAttribute { public DateValidationAttribute(string leftDateProperty, CompareOperator compareOperator, string rightDateProperty, string errorMessage) ...

Can I run an ASP.NET MVC2 website with a database from the iPad locally? (iPhone)

I really want to run my test websites from an iPad to show to clients but I don't want to have to rely on the 3g connectivity or wifi. Can I run sites that are compiled from an App or something similar on the iPad? I have seen Mono Touch but I wanted first hand views on this as if I can I'm going to buy an iPad ASAP. ...

How do you centralize error message text, prompts, and other site verbiage?

I'm using ASP.NET MVC 2.0 and C#. I've done this before by rolling my own solution using the database, but I was wondering if there's an easier way or an established practice for doing this. I'm also hoping the solution I choose makes it easy to support multiple languages later. ...

Fire post on Ajax.BeginForm with JQuery

Hey, I have this MVC form with 2 dropdownlist where selection on the first dropdown should update the second one through an AJAX call. Form looks as follows: <%using (Ajax.BeginForm("GetChildren", "Home", null, new AjaxOptions { UpdateTargetId = "result" }, new Dictionary<string, object> { { "id", "someForm" } })) { %> <%= Html.DropDo...

asp.net mvc 2 render view to string, instead of partial

Hello I have this function: public static string RenderViewToString(string controlName, object viewData) { ViewDataDictionary vd = new ViewDataDictionary(viewData); ViewPage vp = new ViewPage { ViewData = vd }; Control control = vp.LoadControl(controlName); vp.Controls.Add(control); StringBuilder sb = new StringBu...

jQuery find elements of class name within same container

I have a UserControl in MVC which may be repeated many times on the page. Say I had something like the following: <div> <a href="#" class="enableTextBox">edit</a>" <input type="text" class="comments" readonly="readonly" /> </div> <div> <a href="#" class="enableTextBox">edit</a>" <input type="text" class="comments" rea...

How do I deploy an ASP.NET MVC web site using Visual Web Developer 2010 Express Edition?

Hey there StackOverflow, I'm having problems deploying my website to the live server using VWD 2010 Express. I had done this without a problem in VWD 2008 Express. But, it seems that the tools for publishing a site are very different from 2008 to 2010. What I've tried so far is to go to Project>Package/Publish Settings and I change ...

ASP.NET MVC Images / CSS not showing for a web application with a web site

I have a number of web applications within my website in IIS 7.5, in which my MVC2 web application will live. WebSite * Prod * Test1 * Test2 I have firewall routing configured to redirect from http://test1.mywebsite.com/xxx to http://my.actual.website/Test1 I've used Url.Content("~/Content/Site.css") but the CSS is not ge...

What's the correct way of accessing reference data in this Domain Data Modelling scenario?

Initial Warning: Long post and I might have got the pattern totally wrong anyway: Given the following class which is the start of the Customer Aggregate: public class Customer : KeyedObject { public Customer(int customerId) { _customerRepository.Load(this); } private ICustomerRepository _customerRepository = IoC.Res...