asp.net-mvc-2

Is there a way to set convention when returning a partial view

Is there a way to set convention when returning a partial view? For example: I have the following: HomeController ---> Home(action Method) --> _Home.ascx (partial view) AboutController ---> About(action Method) --> _About.ascx (partial view) I'm currently passing the partial view name explicitly to the PartialView helper(ie return P...

JSON Date parameter passed to MVC Action is always null

I have a range of parameters that are passed via jQuery Ajax to an MVC JsonResult action. For the most part, these arrive successfully, but there is a Date value that is not arriving at all. What considerations / formats do I need to use - or what approaches do I need to take - in order to get this date to arrive successfully? ...othe...

Validate a model in viewmodel?

Hi. I wonder if there is a way to validate just one of my models in the viewmodel send it to my action? I use the DataAnnotations as validate rules. Like the if (!ModelState.IsValid) let me know if the question is unclear and I will edit for a better explination EDIT my viewmodel looks like this public class CompaniesViewModel { ...

Implementing Google Analytics in Asp.net mvc

I want to integrate Google analytics in my asp.net mvc application. So im doing some R&D for it to find out which one is the better. I find out a Google Analytic Dashboard Controls which are available at http://gadashboardcontrols.codeplex.com/ But they are server control and im not sure how to implement in asp.net mvc. Secondly can...

Second layer of authentication in ASP.NET MVC2 application

We have an ASP.NET application that's partly in MVC (the rest of it being a legacy webforms-based CMS). The application is authenticated via Forms Authentication, although any user accessing it from a specific set of IP addresses are automatically assigned to a "special" user. We currently have a child application that we would ideally...

format property in class to return phone number

Is it possible to format what I have below to return a phone number? private string _Phone; [DataMember] public string Value { get { return String.Format("{0:(###) ###-####}", Int64.Parse(_Phone)); } set { _Phone = value; } } ...

ASP.NET MVC multiple url's pointing to the same action

Hey there How do i map multiple url's to the same action in asp.net mvc I have: string url1 = "Help/Me"; string url2 = "Help/Me/Now"; string url3 = "Help/Polemus"; string url1 = "Help/Polemus/Tomorow"; In my global.asax.cs file i want to map all those url to the following action: public class PageController : Controller { [Http...

JQuery post function problem

Hi! I try to post some data via json objects to my asp.net mvc view, here is the code $("#submitButton").click(function () { var name = $("#name")[0].valueOf(); var price = $("#price").valueOf(); var url = $("#url").valueOf(); var product = { Name: name, Price: price, Url: ur...

Copying Models Between Layers

When traversing layers it is very tedious to perform right->left assignments as a way to populate the models. For example: employeeViewModel.FirstName = employeeModel.FirstName; employeeViewModel.LastName = employeeModel.LastName; ... So, we can build a ModelCopier which uses reflection to copy models: var employeeViewModel = ModelC...

ViewResult returns no data

Hi! I am using the pattern from NerdDinner. I call Index() in my test Method and I the ViewREsult I get back has no data. So the variable data ends up being null. However, I know that there is data there. Because I can go to the watch window and expand the variable result and expand viewData->Model->ResultsView then I see the "expandi...

How to pass information from controller to viewdata? asp net mvc c#

I am building a pagination my mvc project and have follew problem. I did everything for pagination and now need just pass a page information to view data in view. I have a user control Pagination: Pagination.ascx: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Pagination.ascx.cs" Inherits="PIMP.Web.TestForum....

Custom Validation Attribute is not called ASP.NET MVC

Hello everyone I have create custom validation attribute and assign it to class level validation. Unfortunately, it is not called. I try every way that it think it could be solve the problem. However, it take me for hours and I can't find the attribute is not called by validation mechanism. For illustrate you I put the following code....

Telerik MVC grid - ArgugumentException when filtering

Greetings, I'm having the problem posted here (the post dated August 18th is mine), but not getting anywhere. In a nutshell, filtering with Telerik's MVC grid causes an ArgumentException with the message "The argument to DbIsNullExpression must refer to a primitive or reference type." Interestingly, if you .ToList() the IQueryable firs...

ASP.NET MVC 2 - Trying to configure role/user management via ASP.NET Configuration Tool

First, my development environment: Win7 laptop with Visual Studio Professional 2010. IIS is NOT installed. I'm trying to turn on and set up some roles for user management via the ASP.NET Configuration Tool, as demonstrated in the MVCMusicStore tutorial. When I click on the 'Security' tab, I get the following error: "There is a proble...

ASP.NET MVC Displaying and automatically refreshing a progress bar for donations

Hello there, I am building a simple ASP.NET MVC site to record and track donations. We have a set goal of $2,500,000 and will be entering donations into a database as they come in. We need to have a meter or progress bar on the homepage to show how close they are to the goal. Right now I have a partialView that has the donationGoal and t...

Resource addressing in MVC applications

I am working on an MVC site that contains overloaded controllers that accept variable parameters. Depending on the parameter count (mysite/{id}) versus (mysite/{id}/{name}/{state}) the relative paths to resources change. The same view may be used by different controllers. How do I best address resources such as script libraries or image...

How to make jQuery post data to Controller and then return to another view page

I'm working on a MVC project and I use jQuery to post data from my Index page to Home controller from view page function Search(){ var _name = document.getElementById("HotelName").value; $.post("Search/", { name: _name }); } In my controller public ActionResult Search(String name){ var Hotel = db.getHotelByName(name); retu...

Ordering Entity Framework sub-items for EditorFor

I've seen http://stackoverflow.com/questions/3565249/ordering-sub-items-within-ordered-items-in-a-linq-to-entities-query which suggests that there is no way of getting the repository to return sub-items in an entity graph in a specific order. If that's right, any thoughts on how to order the items in an EditorFor ? i.e. //This works ...

Any changes to model binding to dictionary<T1, T2> in ASP.NET MVC 2?

I know that in ASP.NET MVC 1 in order to bind dynamic form values to a dictionary, dictionary keys must be integer, zero based and non-breaking. Is it still the case with ASP.NET MVC 2? I'm struggling to get default model binder to fill the Dictionary<Guid, Guid[]> from dynamic checkboxes but can't get it to work. It seems that custom mo...

Submit PartialView

Hey There I have a masterpage that render's the following PartialView: <% Html.RenderPartial("AddPage); %> AddPage Controller looks like this: public class PagController : Controller { [HttpGet] public PartialViewResult AddPage() { return PartialView(); } [HttpPost] public PartialViewResult AddPage(F...