Asp.net mvc 2 Getting buddy class information?

I'm trying to read buddy class metadata information for usage outside of the normal asp.net mvc 2 validation process. I thought it would be as simple as saying: DataAnnotationsModelMetadataProvider metadataProvider = new DataAnnotationsModelMetadataProvider(); var metaData = metadataProvider.GetMetadataForType(() => new T(), typeof (T)); That works, but is returning me the entire types metadata information and not just what is in the buddy information. According to the MVC2 source ( It

Asp.net mvc 2 Asp.net MVC Label For

I have the following <label for="Forename">Forename</label> <%= Html.TextBoxFor(m => m.Customer.Name.Forename) %> the problem with this is that this is rendered as <label for="Forename">Forename</label> <input type="text" value="" name="Customer.Name.Forename" id="Customer_Name_Forename"> not what I want ofc. I would like an extension to render the label correctly (i.e. with the for="" attribute having the value of the input id), is there anythin

Asp.net mvc 2 What is the best way of making a mobile version of a site in asp.net MVC2?

I've been thinking about this recently and I don't know a really nice and tidy way of creating a mobile version of an existing or new MVC2 website/app. I think the easiest way would be to just use a different stylesheet depending on whether a mobile was detected but sometime you need to change the view content too if you have massive inline images everywhere or for other reasons. What is a good approach for this? Is there a way of theming fairly easily in MVC2?

Asp.net mvc 2 Render Partial of same name as parent View - Crashes WebDev.WebServer40.exe

I'm wondering whether other people are having this same issue or whether it's just me ! Given I have a View Purchases.aspx and a partial view Purchases.ascx: Within Purchases.aspx if I do: Html.RenderPartial("Purchases") then WebDev.WebServer40.exe basically closes. I'm guessing that this is caused by a Stack Overflow because RenderPartial cannot determine what it's supposed to render (.aspx or .ascx). Is this a bug, is it a defined behaviour, or is it just happening for me?

Asp.net mvc 2 Making my first Create Page with ASP.Net MVC2

I am attempting to generate my first MVC application. I have a very basic table: Teams: ID,Name. I have created the MVC app ok and the table is listed. Below is the Create View. When it is run I get the message: A value is required. Can you help (sorry this is very basic). View create.aspx: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GettingStarted.Models.Team>" %> <asp:Content ID="Content1" ContentPlace

Asp.net mvc 2 MVC Repository Pattern/Web Services SoC Question

I am new to ASP.NET MVC and I am trying to implement best practices for a small-to-mid size application that uses a web service as its data source. The web service exposes the following methods to support the application: AuthenticateCustomer - returns the customer ID if valid email/password GetCustomer - returns a serialized object containing customer information Etc My question is, all of these services return Success (bool) and Message (string) values depending on the result of the opera

Asp.net mvc 2 When I add FormsAuthentication to ASP.NET MVC2 site in IIS7.5 I get HTTP 403.14 error

I have written a custom forms authentication module and when I add it to the web.config of my MVC2 application and run under IIS7.5 I get the HTTP 403.14 error. If I try to navigate to any of the routed Urls then I simply get a 404 error. The annoying thing is that I did all the testing using Cassini with no problems at all. I have applied all of the fixes from all similar issues to no avail. The problem seems to be that with my module registered Mvc Routing stops working. Clearly it would seem

Asp.net mvc 2 Passing the form action attribute to a Partial View

I have a partial view that I am using from 2 different forms. In order to use jQuery validation I would like to use the tag instead of the Html.BeginForm helper. This means that I should specify the action attribute myself just like ASP.NET MVC 2 does when I call the Html Helpers. My questions are: How can I do it? Are there better ways to do what I want to do?

Asp.net mvc 2 Http post request not being noticed on MVC ASP.NET Deployment

I have two an action method - > RoleURLManagement which differs with its input parameter in the get compared to the post so we have [AcceptVerbs(HttpVerbs.Get)] public ActionResult RoleURLManagement(string id) { } and [AcceptVerbs(HttpVerbs.Post)] public ActionResult RoleURLManagement(aspnet_Roles rt) { } The get is bringing back a page based on the id in the URL. The Post should be updating that record. Now, this works perfect locally on my machine

Asp.net mvc 2 Entity Framework 4.0 with POCO classes - Repository pattern?

i'm writing an asp.net mvc 2 web application with Entity Framework 4.0. I have the views that should display items, views that are for login, etc. Should i structure the project with a repository pattern? If yes, how? Should i create an interface for basics methods like Add, Update, Delete, etc and another class that use the repository for the common methods like login validation, etc?

Asp.net mvc 2 MVC2 model binding w/ many-to-many: at the cusp

I'm an inch away from getting my Create form working. My problem is that some data passed into the form in the view model isn't being sent back in the postback. Models: Game: GameID - int (primary key, auto-incr) GameTitle - nvarchar(100) ReviewText - text ReviewScore - smallint Pros - text Cons - text LastModified - Datetime GenreID - int (foreign key from Genres) Platform: PlatformID - int (primary key, auto-incr) Name - nvarchar(50) GamePlatform (n

Asp.net mvc 2 Multiple file upload using Request.Files["files"] MVC

This is my Code. I want to uplade 3 file into my database first in View I write this : <% using (Html.BeginForm(Actionname, Controller, FormMethod.Post, new {enctype="multipart/form-data"})){%> ..... .... and this is 3 file uplaoding: <input type="file" name="files" id="FileUpload1" /> <input type="file" name="files" id="FileUpload2" /> <input type="file" name="files" id="FileUpload3" /> In controller I use this code: IEnumerable<HttpPostedFileBase> files = Reque

Asp.net mvc 2 Asp MVC 2: Typed Editor Template

(I reference this tutorial in this text) I want to use the Html.EditorFor (or Html.Editor) helpers. If a UserControl needs additional data it is passed via ...EditorFor(model => model.Album, new { Artists = Model.Artists, ... }) In the UserControl it's accessed via ViewData[stringKey], ie ... new SelectList(ViewData["Artists"] as IEnumerable, ... To me this smells a little fishy as I would prefer a strongly typed ViewModel which ensures that specific data is available. I'm now a littl

Asp.net mvc 2 MVC2 code conversion in Razor

I am using someones code for paging. His code is in MVC 2 and I want it in MVC3 Razor. Problem is with syntax. Below is the code in mvc need someone to fix syntax for razor please. Problem is in this line IList<Customer> customers = (IList<Customer>)Model.Data; //Can't use Model.Data directly. Doesn't pick up generic type. IList<Customer> customers = (IList<Customer>)Model.Data; foreach (Customer item in customers) { %> <tr onclick="onRowClick(<%= item.I

Asp.net mvc 2 Understanding configuration for parallel calling in web app (IIS + MS SQL)

We have an ASP.NET MVC application + IIS 7.5 + SQL Server 2008 R2. We have to load a lot of aggregate counters on the each page. We decided to use ajax and call with javascript for each counter or groups of counters and return them as JSON result. We solve the problem that user doesn't wait for page loading, page loads fast. User waits for counters loading while seeing other page content. But we thought that if we make calls from javascript - our queries will be make async, but we notice, tha

Asp.net mvc 2 Collections.Generic.Dictionary<TKey,Tvalue> model binding from Viewmodel to controller

i have this problem : when i try to post submit from a View to a httppost actionResult i get always a null value. this is my code : public class WhiteListViewModel { public string Badge { get; set; } public IEnumerable<string> Selezioni { get; set; } public IEnumerable<bool> Abilitazioni { get; set; } } public ActionResult WhiteList() { return View( "Whitelist", MasterPage, new WhitelistViewModel()); } [HttpPost] public ActionResult WhiteListp(IEnumerable

Asp.net mvc 2 ASP.net MVC application logging out very quickly after logging in

This is probably a very simple problem but I cant see the solution and its really beginning to bug me! I have a simple ASP.Net MVC2 application which is intended as a learning aid which requires users to log in by providing username and password. These are authenticated against a DB using a membership provider was created and configured using the aspnet_regsql tool. The web config looks like this (which I think is right... maybe not sure about the forms authentication bit however): <authen

Asp.net mvc 2 EF4 EntityException - The underlying provider failed on Open

Okay, this is a new one. I'm trying to debug my project, which I've done many times in the past, and I'm now getting this exception in one of my repositories. I haven't seen it before now. I haven't touched my repos in days, and my connection string is the same as its always been. The inner exception states: {"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name i

Asp.net mvc 2 asp .net mvc change password issue firefox

//UPDATE : Described problem occurs only in Firefox Browser I've written small app in mvc 2.0, which uses aspnetdb to manage users and standard Account controllers / views etc. My problem is when i try to change password for user sometimes after typing old password and putting new password, another window opens where i can (?) choose user to change password. It is very strange, it happens only to some users in application while for other it works quite fine. Could anyone give me any suggestion w

Asp.net mvc 2 Converting an inventory system from ASP.NET MVC2 to Sharepoint 2010, any issues to expect?

While waiting for a Sharepoint 2010 install, I am creating an intranet inventory system using ASP.NET using the MVC2 and entity frameworks in Visual Studio 2008 and SQL Server 2005(I believe) For some of the client side stuff, I am using jquery(date picker,some AJAX posting, etc). The inventory system includes a list of stocked equipment as well as a check-out system. My DB structure for the inventory system makes use of PK/FK relationships: Table for basic request information Table for req

Asp.net mvc 2 ASP.NET MVC DefaultValue attribute vs C# Optional Argument

What is the difference between this ASP.NET MVC2 method signature, which uses the DefaultValue attribute: public ActionResult DoStuff([DefaultValue(MyEnum.Alpha)] MyEnum enumToUse, bool printPage = false) { //... } And this signature, which instead uses a C# 4.0 optional argument? public ActionResult DoStuff(MyEnum enumToUse = MyEnum.Alpha, bool printPage = false) { //... } Are the two statements different in any functional way, or is it just a matter of preference?

Asp.net mvc 2 checkboxlist in asp.net MVC

I want to create a checkboxlist in asp.net mvc view and want to display week days (monday tuesday, ....). I want to save the value(s) selected by user in database. How can I do this in MVC2 Someone suggested me to use "Enumeration Types as Bit Flags" mentioned here: http://msdn.microsoft.com/en-us/library/cc138362.aspx how can I use it ? Please suggest solution.

Asp.net mvc 2 Simulating timeout on ASP.NET MVC

Problem: I need to create a web project with a controller that times out. What I have done: Create a new web application Empty the web.config, and write the values below: . <?xml version="1.0"?> <configuration> <system.web> <httpRuntime executionTimeout="1" /> <compilation debug="false" /> <httpModules> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0,

Asp.net mvc 2 How to get the value of lambda expression in asp .net mvc2?

I have a action result method where it gives values from the database and Iam passsing this values to the view and the values will be populated in the textboxes but i have radio button to be selected depending on the value of the database,example if the value is male then radiobutton as to be selected else radiobutton female aas to be selected.I have written the code <% if(model=>model.Gender) {%> <%= Html.RadioButtonFor(model => model.Gender, "Male", "Checked")%>

Asp.net mvc 2 About using the Microsoft Chart library and a general clarification sought in C#

I am using the Microsoft Chart. I have a UI to get the value for each property of this object. Then i store all these values in the DB. Now that I have the properties from the DB I have to bind them to the corresponding properties of the Chart object. Which is the most efficient and right way. Shall i do it using reflection or other ways. I came to know that this class has a method that can export all the settings for the chart, including the values in an XML format. What if i can try to cr

Asp.net mvc 2 MVC2 and Google Custom Search

I am trying to incorporate google custom search in my MVC2 application. I have already registered for google custom search and obtained API key and other settings. I have an input type textbox on my view and a search button. How can now i pass the search string (from my textbox) to google API and receive the search result and show them on same or other view page? any related post, example would be a great help.

Asp.net mvc 2 null reference object showing error

I have locationid in candidates table. I want to show this one in details page. If Locationid is empty means db stored 0 value. otherwise the id value is there. when I try to display in details page, whenever id have 0 value showing following error, Even I check Null conditions too. **"object reference not set to an object"** My code is, <%if (Model.LocationId != null) { %> <% if (Model.GetLocation(Model.LocationId.Value).CityId != null) {%>

Asp.net mvc 2 Why is my asp:Substitution control suddenly not working in ASP.NET 4.0?

I just upgraded my site from ASP.NET 3.5 to 4.0. I've been working through some breaking changes and there were more than I expected. One I can't figure out, however, is why my <asp:Substitution /> control suddenly stopped working like it should. It's supposed to ignore the output cache settings of the parent page and update upon every request. For some reason that isn't happening. It's caching for the full 10 minutes (the OutputCache setting for my home page). Any ideas?

Asp.net mvc 2 MVC2 Areas and unit testing for routes

I want to test my routes in unit tests. But Areas is not working in my unit tests. Is it possible to test ASP.NET MVC 2 routes for Areas? I am using this code [SetUp] public void SetUp() { this.routes = new RouteCollection(); MvcApplication.RegisterRoutes(this.routes); } #endregion private RouteCollection routes; [Test] public void Should_Navigate_To_AdminUser_Controller_EditUser_Method() { HttpContextBase fackeCtx = CreateFackeContext

Asp.net mvc 2 How to route lower-case URLs ('questions/add_to_favorites/123') with underscores in ASP.NET MVC2?

ASP.NET MVC 2 controllers and actions use UpperCamelCase. For some reasons many big sites, including SO, use lowercase (with underscore) for controllers and actions in the urls. Examples: https://stackoverflow.com/questions https://stackoverflow.com/users/377920/randomguy http://www.reddit.com/ad_inq/ http://www.wired.com/special_multimedia/mobile/ etc. I would like to know how this is accomplished. The default router seems to be case-insensitive, ie. stackoverflow.com/questions/ask will be

Asp.net mvc 2 How to create an MVC 2 dropdown user control for use in multiple views

I'm new to MVC and the new paradigm hasn't clicked yet. I want to create a user control that is a simple dropdown and uses data from a database to populate its items. The dropdown would be useable in any view I chose. At this point I don't need the control to be data/table agnostic, I'd settle for making the user control strongly typed like a view. The scenario I'm looking at currently is to use the SelectedIndexChanged event (or its equivalent in MVC 2) to populate a table of related data. He

Asp.net mvc 2 Better approach to role-based UI changes?

I have an MVC view that changes a few small UI elements based on the user's role. Currently it modifies the output using a few if() statements using a couple boolean values I sent to the view through the viewmodel. However, it doesn't seem like a very good approach, so what I'd like to do is move this all into either an HtmlHelper class or the controller itself. Here's the current code: <% if ( Model.IsAdmin ) { %> <td> <% } %> <%--Opening tag for admin options--%> &

Asp.net mvc 2 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 <%: Html.ActionLink("Home", "Index", "Home")%> in my view, it defaults to /Framed/Home/Index. I believe this is because the framed namespace is added first in m

Asp.net mvc 2 Best Practice for handling multiple authentication providers for MVC ala stackoverflow

I'm looking for suggestions on how to handle multiple auth providers like twitter, facebook, google, openid within an MVC app. What is the general idea? I've got my own user detail table and i'm currently using ASP.Net membership authentication. When someone connects with facebook are you able to extract user detail information from them via a cookie or directly from facebook? Do people typically store this in their local database? I guess i'm looking for a broad overview. I've read some tuto

Asp.net mvc 2 How does forms auth work with ASP.Net MVC2

I am having a hard time to get Forms Auth integrated in my MVC2 site. I googled and searched and tried different things, read msdn docs, but nowhere a decent tutorial on how to do it the MVC way. I have an application, and I set up users and roles with the wizard. And I made a controller with a logon action with a LoginControl. Now what do I do next? How do I logon a user and redirect to where he came from?

Asp.net mvc 2 ASP.NET MVC 2: foreach, RenderPartial, ViewModel

I'm trying to employ a technique that I came across that seems quite clean. Previously, my Partial had the loop inside of it. I was looping through the mode within the Partial... but then I came across an example where the foreach loop existed in the main page, while the partial was just the meat of the loop. They accomplished it like so: <% int index = 1; // iteration foreach (var item in Model.Deal) { %> <% Html.RenderPartial("DealList", item, new ViewDataDictionary {{ "index

Asp.net mvc 2 Forcing all controls on MVC2 form to validate using JQuery

Is there a way (using JQuery or Java Script) to force an MVC2 form to perform validation on it's fields with Data Annotation validation without posting back to the server? I have a MVC2 form that is quite complex. Many of the fields are hidden or displayed depending on other selections. Given this, some of the fields are validated using Data Annotations and some are validated using custom JQuery. In the case that one of the fields with custom validation fails it's validation I wish to prevent

Asp.net mvc 2 dotnetopenauth - popup window does not close after authentication

I'm using dotnetopenauth to as my open id lib. in all browsers the popup being close after authentication except for IE. I'm doing the authentication as follows: Using window.open I opens the Authenticate action and after successfully authenticate return the following view: if (window.opener.isUserLoggedOn()) { window.opener.OnUserLogonFinished(); window.close(); } else { window.close(); } In all browsers the opener is accessible except for IE. Any he

Asp.net mvc 2 html.textbox datetime format

is it possible to format a text box at page level (not viewmodel) so a datetime can exclude the time stamp? i cant edit the viewmodel in this project.. so i have to pass in to the view the viewmodel containing a datetime property. <%=Html.TextBox("DateOfBirth", Model.DateOfBirth)%><br /> thanks

Asp.net mvc 2 Dynamic controls with mvc client validation

I have an MVC 2 app and I am using client side validation. The form has a portion of it where the fields are built dynamically from the database. I want to also allow client side validation for any field that is supposed to be a totalled field (numeric). So, I took the big blob of validation code and built a matching statement //<![CDATA[ if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; } window.mvcClientValidationMetadata.push({ "Fields": [{ "Fi

Asp.net mvc 2 if(ModelState.IsValid) doesn't work with FormsCollection. What to use instead?

To validate a HttpPost action that's bound to a concrete type, I can use ModelState.IsValid public ActionResult Create(MyModelType myModel) { if(ModelState.IsValid) { // Do some stuff return RedirectToAction("Details", 0); } else { return View(); } } This obviously won't work with a FormCollection, because there is no model to validate public ActionResult Create(FormCollection collection)

Asp.net mvc 2 log4net RollingFileAppender and IIS 7.5

I'm trying to use log4net with a RollingFileAppender on IIS 7.5 / Server 2008 R2. However, the configuration from my old IIS 6 / Server 2003 box doesn't appear to work anymore, I simply don't see any log files being created, here's what I've got setup: In Web.config (inside <configSections>) <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> In the same file (inside <configuration>) <log4net> <appender name="Console

Asp.net mvc 2 MVC 2 - Are Sattelite assemblies required for embedded resources? Embedded resources not working

Hello I have been working on an MVC 2.0 web application. This has the requirement to switch between 2 languages. The existing solution did not work well as the MVC [DisplayName] attributes and data annotation error messages etc did not work as they were not culture aware in MVC 2.0. I followed the example here: http://adamyan.blogspot.co.uk/2010/02/aspnet-mvc-2-localization-complete.html#!/2010/02/aspnet-mvc-2-localization-complete.html With a few tweaks it is all working perfectly in my Visu

Asp.net mvc 2 C# MVC2 DropDownListFor bug after submit

I am trying to fix a bug on an MVC2 page with a dropdown. My problem is that after submitting the form, I change a value in my model server side for the dropdown but when the view is rendered again the new value is not selected. I have defined my dropdown in the view as follows. <%= Html.DropDownListFor(m => m.MyValueId, MyHelperClass.GetMyDropdown())%> I have a helper class to generate my dropdown list, the function looks like this. public static List<SelectListItem> GetMyDr

  1    2   3   4   5   6  ... 下一页 最后一页 共 11 页