asp.net-mvc-2

How to I access validation metadata in my view?

I want to add a 'required field' label to those fields in my model that I have set the Required attribute for. How do I go about doing this? ...

Generate links for routes with non-parameter url segments on ASP.NET MVC 2

Hi everyone, I have a route defined with several hardcoded (non-parameter) segments: routes.MapRoute(null, "suggestion/list/by/{tag}", new { controller = "Suggestion", action = "List", tag = UrlParameter.Optional }); Suppose I'm in the Index view of SuggestionController, which has a Suggestion object for Model, how can I crea...

Problems with Master Page in ASP.NET MVC

What i need use to render a widget without use contentplaceholder?? ...

How to bind dropdownlist data to complex class?

Hi I am using asp.net mvc 2.0(default binding model) and I have this problem. I have a strongly typed view that has a dropdownlist <%= Html.DropDownList("List", "-----")%> Now I have a model class like Public class Test { public List { get; set; } public string Selected {get; set;} public Test() { List ...

Hide editor-label for public property when calling EditorFor(...)?

When calling Html.EditorFor(m => m), where m is a public class with public properties, a hidden input and a label are displayed for properties with the [HiddenInput] attribute. How can I hide the label without making it private or creating an editor template? Example public class User { [HiddenInput] public Guid ID { get; s...

protected access specifiers in singleton class

HI, In singleton class we are declaring constructors as private. Is it possible to give as protected. If giving as protected is it beneficial. Whats the advantage or disadvantage of private over protected ...

T4MVC and duplicate controller names in different areas

In my application I have controller named Snippets both in default area (in application root) and in my area called Manage. I use T4MVC and custom routes, like this: routes.MapRoute( "Feed", "feed/", MVC.Snippets.Rss() ); And I get this error: Multiple types were found that match the controller named 'snippets'. This c...

asp.net mvc datatable

How can I pass datatable to the mvc view How would I iterate over it in the view ...

Add onblur event to ASP.Net MVC's Html.TextBox

What's the correct syntax for an HTML helper (in MVC2) to define an onblur handler where the textbox is generated with code like: <%=Html.TextBox( "ChooseOptions.AddCount" + order.ID, (order.Count > 0) ? AddCount.ToString() : "", new { @class = "{number: true} small-input" } ) thx ...

Using *.html extension in dynamic UR's for SEO

Hi all My situation is. I have a project planned to be built on ASP.NET MVC 2. And one of the major requirements is SEO optimization. A customer wants to use static-like URLs that end up with .html extension for this project that make URLs more SEO friendly. E.g. "mysite.com/about.html " or "mysite.com/items/getitem/5.html" etc. I won...

MVC 2: Html.TextBoxFor, etc. in VB.NET 2010

Hello, I have this sample ASP.NET MVC 2.0 view in C#, bound to a strongly typed model that has a first name, last name, and email: <div> First: <%= Html.TextBoxFor(i => i.FirstName) %> <%= Html.ValidationMessageFor(i => i.FirstName, "*") %> </div> <div> Last: <%= Html.TextBoxFor(i => i.LastName) %> <%= Html.ValidationMe...

How to mass insert/update in linq to sql?

Hi How can I do these 2 scenarios. Currently I am doing something like this public class Repository { private LinqtoSqlContext dbcontext = new LinqtoSqlContext(); public void Update() { // find record // update record // save record ( dbcontext.submitChanges() } public void Insert() { // make a dat...

Can't launch asp.net mvc 2 application from iis 7.5

Hello. I'm trying to launch my mvc 2 application from iis 7.5 and get HTTP 403.14 - Forbidden error. That's what I did: 1. Went to add or remove windows fitures checked iis, asp.net, http redirect. Installed all this stuff. 2. Launched Visual studio 2010 (release), created standart mvc 2 project and published it in default web site/Appli...

What is the correct way to create dynamic javascript in ASP.net MVC2?

I'm creating a Google Maps partial view/user control in my project that is passed a strongly typed list of objects containing latitude and longitude values. Currently, this is the code I have for the partial: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Project.Models.Entities.Location>>" %> <!-- Place...

Rendering a View without a Master Page

Heya, I'm fetching a page using ajax (jquery) and appending certain data to the Requests query string to let the server know it shouldn't render the entire Page, just the view in question to the output buffer. I'm having no luck though, I can detect when the page needs to be rendered partially, but everything I've tried so far (includin...

multiple partial views mvc 2

Hello World! Hi guys, I have a master page with two partial viewson it both of which submit to the AccountController. When I click Submit on either of the partial views the following happens: If I declare the partial views like Html.BeginForm("PartialAction1","Account") it redirects to that partial view on clicking submit instead brin...

How do I clear MVC client side validation errors when a cancel button is clicked when a user has invalidated a form?

I have a partial view that is rendered within a main view. The partial view takes advantage of System.ComponentModel.DataAnnotations and Html.EnableClientValidation(). A link is clicked, and div containing the partial view is displayed within a JQuery.Dialog(). I then click the save button without entering any text in my validated inp...

ForEach with EditorFor

I have got an Entity model which contains a collection of Message objects which are of the type Message which has several properties, including content, MessageID, from, and to. I have created an EditorTemplate for type Message, however, I cannot get it to display the contents of the Messages collection. There are no errors, but nothin...

Page modules like DNN in asp.net mvc

I want to create a dnn like page modules in asp.net mvc site. Can any one have idea how i can do that. I am using asp.net mvc2. Any tip of code will be great help Thanks in advance. ...

How do build a composite or template control in ASP.Net MVC, or the equivelant?

In our current ASP.Net Webforms application we have several composite/template server controls that only exist for a common look and feel. For example, we have a panel control that has a title, a place for buttons related to the contents of the panel, and of course the contents. How is this best accomplished in MVC? RenderPartial does...