asp.net-mvc-2

Updating a list of foreign keys in EF4, using MVC 2 Repository Viewmodel Pattern.

Okay, I'm really struggling with how to update a list of foreign keys in MVC2/EF4. I have a one to many relationship between a Template object which can have many or no TemplateScenario objects. Essentially, I have an edit method in a controller that is trying to do this: // POST: /Modes/Edit/1 [HttpPost] public ActionR...

Create a mailto anchor tag in MVC2

Is it possible in MVC2 to create an anchor tag that contains values from ViewData? e.g. <a href="mailto:<%: ViewData["Email"] %>">Send Email</a> This code above doesn't render and just throws an exception? ...

Asp.net MVC and IIS 7 Remove Basic Authentication in web.config

I published a site with a web hosting company and when someone hits the URL for the first time they are being prompted to log in using basic authentication. If you hit Cancel the site loads successfully and the user is not prompted again with the dialog box. I contacted support and they are telling me (in a canned response) that it’s a...

Allow special characters for password

In my MVC2 site if a user enters lt/gt signs in a password box an exception is thrown because of "potentially dangerous..". ValidateInput(false) on my controller solves it but for something so simple (not html passing) yet needs to be protected what is a better alternative? I've briefly looked at http://wpl.codeplex.com/ but it also seem...

Complex Data Validation using Data Annotations

I have the following class public partial class Contact { public Contact() { } #region Primitive Properties public virtual int Id { get; set; } [Display(ResourceType = typeof(Common), Name = "Person_Name")] [Required(ErrorMessageResourceName = "Validation_Required", ErrorMessageResourceType = typeof(Common...

Updating Html.Dropdownlists using JQuery

I found this solution on here http://stackoverflow.com/questions/2782815/how-to-update-strongly-typed-html-dropdownlist-using-jquery and am trying to implement it, but something is bugged in it. $(function() { $('#cid').change(function() { var selectedCompany = $(this).val(); var ddl = $("#foid"); $.post("/Ti...

MVC 2 - How to set the namespace targeted by an actionlink

I have 2 namespaces for my controllers. One is the default MyProject.Controllers and the second is MyProject.Controllers.Framed. I am using namespaces so that I can have a url like /home/index serve up the normal home website and /framed/home/index serves up a version intended for use in an iframe. My problem is that when I put <%: Ht...

How to mock Request.Form in NMock2?

Hi Guys, Has anybody mocked Request.Form in NMock2. I found a sample for MOQ but dont know how to translate that in NMock2. var request = Mock.Get(controller.Request) request.Setup(r => r.Form).Returns(delegate() { var nv = new NameValueCollection(); nv.Add("UserName","SomeUser"); nv.Add("Email","[email protected]"); retur...

Passing ViewModel (containing request parameters) across Controllers

I have few questions based on following scenario: I have a LoginController with following methods: public ActionResult Login() { return View(); } [HttpPost] public ActionResult Login(UserObject user) { Calling Besiness Service to Validate User againts DB (Using Repository)... if (success) { return RedirectT...

How can I get ValidationSummary messages programmatically?

I've created an HtmlHelper that helps me show a jQuery modal dialog: I set a message in controller's TempData and if the message is not null, the helper writes an jquery + html code to make popup apears after postback. But I need to show the Validation results as a message (same message displayed by ValidationSummary), and I have no Ide...

MVC 2 route from form GET? Or POST?

Hi All, I have a small form with a single textbox and a submit button. using (Html.BeginForm("Index", "Tag", FormMethod.Post) In my tag controller i have a method that looks like: public ActionResult Index(string tagText) I'm trying to figure out first how to route this so the resulting URL will look like: http://mydomain.com/Tag...

How can i highlight the current page on menu when using OutputCache with ASP.Net MVC 2 ?

Hi, I have a menu which is created from the database. When the users navigate through pages the current page is highlighted with the css class. Menu is rendered with the Html.RenderAction("Menu","Home"); Because of being datadriven menu i use the new ChildActionCache attribute which is in the ASP.NET MVC 2 Futures project to cache t...

C# MVC2 - Setting a label on Master Page from a Content Page

I have a dropdown list that is populated on a content page like this <%: Html.DropDownListFor(x => x.SelectedName, Model.NameList) %> <input name="btnGo" type="submit" value="GO" /> When the user selects the name and click the GO button, I have an HTTP Action that gives me the name [HttpPost] public ActionResult SelectName(string S...

DropDownListFor population problem

I have the following 2 classes: public class SomeClass { public int SomeClassID { get; set; } ... } public class AnotherClass { public int AnotherClassID { get; set; } public int AnotherClassText { get; set; } } I have a ViewModel that contains the following: public class MyViewModel { public SomeClass { get; set; } publ...

.net 4 mvc2 output caching substitute name

Hi, I have output caching implemented at controller level [OutputCache(CacheProfile = "MyProfile")] public Result MyControllerAction().... I have some text in matching view (Views/MyController/MyControllerAction.aspx) that needs to change with each page load, even though the returned page is cached. I think this is also called donut ...

All the data annotations (or attributes) availabe in Asp.net M-V-C

Is there any way to look at all the data annotations or attributes available in Asp.net MVC? i.e. for validation we have "Required", "StringLength" etc, for Action verbs, "HttpPost", "HttpGet" etc, similarly "Bind", "MetadataType" etc. I am kind of new to Asp.net MVC and MVC is loaded with attributes for different purposes and I don't k...

Create a method that will return a Lambda Expression that will be use in a lambda WHERE clause. Got error 1025.

I use Framework Entity 4 in my project. I would like to create a function that will return an Expression Nothing seem to work. I get this Internal .Net Framework Data Provider error 1025. Here is my Expression Method public Expression<Func<SupplierTypeText, bool>> GetLmbLang() { return (p => p.LangID == 1); } I call...

Refreshing a dropdownlist after elements have been reset

Hi, i have an asp.net mvc 2 application, and have some jquery that defines behaviour of two dropdownlists. When one changes, the other is populated with filtered data. After much furor, i have the jquery working, confirmed by firebug debugging, but my dropdownlist is not refreshing. This is the jquery <script type="text/javascript"> ...

asp.net mvc logic

i'm starting to develop an asp.net mvc cms. i want to backend for administrator and frontend for users, how i need to build my structure? for now the cms will handle just simple pages with title and body. in the frontend i need to show the menu (pages). in the backend i need to allow view pages list, crud (create,read,update,delete) pag...

Printing using c#/ASP.NET MVC2

I am developping an intranet ASP.NET MVC2 application for a small business. The small business has multiple type of printers and depending on what is required a print request will be sent (from the browser/user) to the server and the server will dispatch the print job to the right printer accordingly. Please note that it is a completely ...