asp.net-mvc-2

3 entities execute the same lambda predicate. How creating one lambda expression generic for these entities.

I Have 3 entities. Product LangID ProductName Category LangID CatName ProductType LangID TypeName As you can see, each of them has LangID Property. I Would like be able to create a generic repository that will contain only one function that will return an Func<T, bool> GetLmbLang() public interface IBaseRepository<T> where T : c...

Problem with UPDATE Operation On Entity Framework 4 (Pure POCOs)

Hi Guys, I have an Entity Framework 4.0 model implemented with pure POCO's (no code generation, no self-tracking entities, just plain old CLR objects). Now, here is some code i have in my UI to perform an UPDATE: [HttpPost] public ActionResult UpdatePerson(Person person) { repository.Attach(person); unitOfWork.Commit(); } Es...

How to provide ASP.NET MVC2 master pages with a model indepdent of the controller

I'm using strongly typed views and autofac for Dependency Injection under ASP.NET MVC2 and I'm trying to get a common dynamic header via dependency injection. I.e. i want this to happen without the view having to be away of this content even existing and i was hoping to avoid static discovery of the container and manual resolution, but I...

how to get server side events on image map in MVC2

please provide me any good link of tutorial/code of how to provide server side events with image map in asp.net MVC2. ...

Unable to get ASP.Net MVC2 project running from MVC source code

I have downloaded the ASP.Net MVC2 RTM source code and I'm trying to run my application against it. For some reason my .ascx controls keep using the non generic ViewUserControl instead of the generic version. My control includes the following line at the top: Inherits="System.Web.Mvc.ViewUserControl<ExistingApplicationLoginModel>...

EF4 error: Unable to load the specified metadata resource

Hi, I have just deployed my ASP.NET MVC 2 application using EF 4 and I am getting the following error: Unable to load the specified metadata resource. On my local machine it runs fine with no errors. This error only comes now when I deployed to the server. I have my enity data model file in MyProject.EntityModel. I used the POCO e...

Insert Html.RenderAction("CartSummary", "ShoppingCart") To Dynamic String ?

I have dynamic strings, for example "hello bold italic {0} xxx {0}yyy {0} etc...", "abcd {0} how to xyz {0} newline {0}..etc..." and more How to insert <% Html.RenderAction("CartSummary", "ShoppingCart"); %> to the dynamic string at the {0} position? Thank You. ...

How to pass parameters while calling controller's function using jquery

I am using below function to call a function on controller: function getPartialView(actionUrl, targetDiv, ajaxMessage, callback) { showAjaxMessage(targetDiv, ajaxMessage); $.get(actionUrl, null, function (result) { $(targetDiv).html(result); callback(); }); } and calling it like t...

Returing multiple Model objects from LINQ Joins

I am using ASP.NET MVC framework and accessing DB records with Entities. I am doing some joins like this: public IQueryable<...> GetThem() { var ords = from o in db.Orders join c in db.Categories on o.CategoryID equals c.ID select new {Order=o, Category=c}; return ords; } I need to use/pass 'ords...

Is there an easy way to set up ASP.NET Membership tables in a custom Database?

ASP.NET Membership is just great as there are a ton of functionality right there to be used, and we don't need to change nothing at all. We can even create our own Provider based on Membership database, and that give us infinite possibilities, like as I don't like the Question/Answer I just use an email that is sent with a reset link. ...

extending the default membership provider in asp.net mvc 2.0

Hi friends,i am new to asp.net mvc 2.0.Currently i am having registration page with fields login id,username,password.now i want to add my own custom fields like first name and last name.So tell me to do this, i have to add these fields in asp_membership table .If i have to add then i have to change the built in stored procedures.My situ...

MVC 2 & TypeConverters, Get the destination type in ConvertFrom where the context is null

I have a TypeConverter on the base class in my project. [TypeConverter(typeof(CodeTypeConverter))] abstract class CodeBase I have a number of classes which inherit this base class TitleCode : CodeBase class PreferenceCode : CodeBase When the thing that calls the type converter (ValueProvider.ConvertSimpleType) it does not create a ...

testing controller using MOQ calling repository

I'm very new to Mocking. In the below example i'm using Moq and trying to create a _companyRepository. However the second test has a null ref. ie Company is not instantiated. Assert.AreEqual(viewModel.Company.Name, "MyCompany"); Think i'm missing something silly here. [TestClass] public class ErrorControllerTest { ...

ASP.NET MVC2 - How to call another controller with RenderAction() as well as pass arguments to that controller?

I'm trying to render a partial view on my master page using Html.RenderAction() in VS 2010 using MVC2. Here is my RenderAction() call: <% Html.RenderAction( "Menu", "Navigation", new { currentAction = ViewContext.RouteData.V...

How to run this code from a Controller?

I found code to export a datatable to excel, but I cant figure out how to get the controller to return the results. any suggestions? here is the code dt = city.GetAllCity();//your datatable string attachment = "attachment; filename=city.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment);...

How to make password field not reset?

I want to edit an user. I dispay the corresponding data(username, email,..etc..password, confirmation pass) The problem is that those password fields are empty. Q: When i display data in the form the two password fields are empty. How can i make them contain data? Thanks. I am using asp.net-mvc 2 <div class="edi...

How can I get 404 to work with Elmah and the HandleErrorAttribute written for Elmah in asp.net mvc?

I have implemented Elmah in one of my ASP.NET MVC projects. In addition I did the following: I implemented the ElmahHandleErrorAttribute written by Atif Aziz in this post I added the attribute to all my controllers I have setup Elmah to filter out 404 errors since I do not want to log those I added an Error.aspx view in the Shared fold...

How do I use the strongly-typed HTML helpers with nullable types?

I want to use the strongly-typed HTML helpers in ASP.NET MVC 2 with a property of my model which is Nullable<T>. Model public class TicketFilter { public bool? IsOpen { get; set; } public TicketType? Type{ get; set; } // TicketType is an enum // ... etc ... } View (HTML) <p>Ticket status: <%: Html.RadioButtonFor(m => m...

Where to store a user specific setting after logon?

In my ASP.NET MVC application I allow users to log in. Each user is associated with a company. Company ID and company data is not part of the Users table in the database. User and Company are connected through a related table (one to many relationship). Company ID is not part of the Users table as a foreign key because the design of the ...

How do I get RouteData in Application_EndRequest

I am building a simple performance logger that hooks in to Application_EndRequest / Application_BeginRequest I would like to send my logger the name of the action and controller as some sort of key. How can I access this information? (Don't mind if I have to intercept it earlier on and keep it around in the context) ...