Search Results

Search found 11138 results on 446 pages for 'spring mvc'.

Page 24/446 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Validation firing in ASP.NET MVC

    - by rkrauter
    I am lost on this MVC project I am working on. I also read Brad Wilsons article. http://bradwilson.typepad.com/blog/2010/01/input-validation-vs-model-validation-in-aspnet-mvc.html I have this: public class Employee { [Required] public int ID { get; set; } [Required] public string FirstName { get; set; } [Required] public string LastName { get; set; } } and these in a controller: public ActionResult Edit(int id) { var emp = GetEmployee(); return View(emp); } [HttpPost] public ActionResult Edit(int id, Employee empBack) { var emp = GetEmployee(); if (TryUpdateModel(emp,new string[] { "LastName"})) { Response.Write("success"); } return View(emp); } public Employee GetEmployee() { return new Employee { FirstName = "Tom", LastName = "Jim", ID = 3 }; } and my view has the following: <% using (Html.BeginForm()) {%> <%= Html.ValidationSummary() %> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%= Html.LabelFor(model => model.FirstName) %> </div> <div class="editor-field"> <%= Html.DisplayFor(model => model.FirstName) %> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.LastName) %> </div> <div class="editor-field"> <%= Html.TextBoxOrLabelFor(model => model.LastName, true)%> <%= Html.ValidationMessageFor(model => model.LastName) %> </div> <p> <input type="submit" value="Save" /> </p> </fieldset> <% } %> Note that the only field editable is the LastName. When I postback, I get back the original employee and try to update it with only the LastName property. But but I see on the page is the following error: •The FirstName field is required. This from what I understand, is because the TryUpdateModel failed. But why? I told it to update only the LastName property. I am using MVC2 RTM Thanks in advance.

    Read the article

  • Asp.net MVC VirtualPathProvider views parse error

    - by madcapnmckay
    Hi, I am working on a plugin system for Asp.net MVC 2. I have a dll containing controllers and views as embedded resources. I scan the plugin dlls for controller using StructureMap and I then can pull them out and instantiate them when requested. This works fine. I then have a VirtualPathProvider which I adapted from this post public class AssemblyResourceProvider : VirtualPathProvider { protected virtual string WidgetDirectory { get { return "~/bin"; } } private bool IsAppResourcePath(string virtualPath) { var checkPath = VirtualPathUtility.ToAppRelative(virtualPath); return checkPath.StartsWith(WidgetDirectory, StringComparison.InvariantCultureIgnoreCase); } public override bool FileExists(string virtualPath) { return (IsAppResourcePath(virtualPath) || base.FileExists(virtualPath)); } public override VirtualFile GetFile(string virtualPath) { return IsAppResourcePath(virtualPath) ? new AssemblyResourceVirtualFile(virtualPath) : base.GetFile(virtualPath); } public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { return IsAppResourcePath(virtualPath) ? null : base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart); } } internal class AssemblyResourceVirtualFile : VirtualFile { private readonly string path; public AssemblyResourceVirtualFile(string virtualPath) : base(virtualPath) { path = VirtualPathUtility.ToAppRelative(virtualPath); } public override Stream Open() { var parts = path.Split('/'); var resourceName = Path.GetFileName(path); var apath = HttpContext.Current.Server.MapPath(Path.GetDirectoryName(path)); var assembly = Assembly.LoadFile(apath); return assembly != null ? assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().SingleOrDefault(s => string.Compare(s, resourceName, true) == 0)) : null; } } The VPP seems to be working fine also. The view is found and is pulled out into a stream. I then receive a parse error Could not load type 'System.Web.Mvc.ViewUserControl<dynamic>'. which I can't find mentioned in any previous example of pluggable views. Why would my view not compile at this stage? Thanks for any help, Ian EDIT: Getting closer to an answer but not quite clear why things aren't compiling. Based on the comments I checked the versions and everything is in V2, I believe dynamic was brought in at V2 so this is fine. I don't even have V3 installed so it can't be that. I have however got the view to render, if I remove the <dynamic> altogether. So a VPP works but only if the view is not strongly typed or dynamic This makes sense for the strongly typed scenario as the type is in the dynamically loaded dll so the viewengine will not be aware of it, even though the dll is in the bin. Is there a way to load types at app start? Considering having a go with MEF instead of my bespoke Structuremap solution. What do you think?

    Read the article

  • Custom model in ASP.NET MVC controller: Custom display message for Date DataType

    - by Rita
    Hi I have an ASP.NET MVC Page that i have to display the fields in customized Text. For that I have built a CustomModel RequestViewModel with the following fields. Description, Event, UsageDate Corresponding to these my custom Model has the below code. So that, the DisplayName is displayed on the ASP.NET MVC View page. Now being the Description and Event string Datatype, both these fields are displaying Custom DisplayMessage. But I have problem with Date Datatype. Instead of "Date of Use of Slides", it is still displaying UsageDate from the actualModel. Anybody faced this issue with DateDatatype? Appreciate your responses. Custom Model: [Required(ErrorMessage="Please provide a description")] [DisplayName("Detail Description")] [StringLength(250, ErrorMessage = "Description cannot exceed 250 chars")] // also need min length 30 public string Description { get; set; } [Required(ErrorMessage="Please specify the name or location")] [DisplayName("Name/Location of the Event")] [StringLength(250, ErrorMessage = "Name/Location cannot exceed 250 chars")] public string Event { get; set; } [Required(ErrorMessage="Please specify a date", ErrorMessageResourceType = typeof(DateTime))] [DisplayName("Date of Use of Slides")] [DataType(DataType.Date)] public string UsageDate { get; set; } ViewCode: <p> <%= Html.LabelFor(model => model.Description) %> <%= Html.TextBoxFor(model => model.Description) %> <%= Html.ValidationMessageFor(model => model.Description) %> </p> <p> <%= Html.LabelFor(model => model.Event) %> <%= Html.TextBoxFor(model => model.Event) %> <%= Html.ValidationMessageFor(model => model.Event) %> </p> <p> <%= Html.LabelFor(model => model.UsageDate) %> <%= Html.TextBoxFor(model => model.UsageDate) %> <%= Html.ValidationMessageFor(model => model.UsageDate) %> </p>

    Read the article

  • Enterprise ASP.NET MVC application architecture

    - by Ben
    I am still trying to figure out the right architecture for a complex ASP.NET MVC web application. I looked in a lot of example code and everywhere it's done differently. I would really appreciate your thoughts on this. Another Question: Would you use Linq to SQL or the Entity Framework? Thanks, -Ben

    Read the article

  • What ASP.NET MVC Route controls the appearance of hashes in URIs?

    - by rasx
    I have integrated a Silverlight Navigation Application in an ASP.NET MVC web. However when Silverlight calls for its default page, say, IndexPage ASP.NET MVC displays the route as: http://localhost/#/IndexPage I have tried to get ASP.NET MVC to respond to this route: http://localhost/#IndexPage but I am unable to find a configuration that works with this. Does ASP.NET MVC routes respond to hashes in general?

    Read the article

  • Learning MVC - Maintaining model state

    - by GenericTypeTea
    First of all, I'm very new to MVC. Bought the books, but not got the T-Shirt yet. I've put together my first little application, but I'm looking at the way I'm maintaining my model and I don't think it looks right. My form contains the following: <% using (Html.BeginForm("Reconfigured", null, FormMethod.Post, new { id = "configurationForm" })) { %> <%= Html.DropDownList("selectedCompany", new SelectList(Model.Companies, Model.SelectedCompany), new { onchange = "$('#configurationForm').submit()" })%> <%= Html.DropDownList("selectedDepartment", new SelectList(Model.Departments, Model.SelectedDepartment), new { onchange = "$('#configurationForm').submit()" })%> <%=Html.TextArea("comment", Model.Comment) %> <%} %> My controller has the following: public ActionResult Index(string company, string department, string comment) { TestModel form = new TestModel(); form.Departments = _someRepository.GetList(); form.Companies = _someRepository.GetList(); form.Comment = comment; form.SelectedCompany = company; form.SelectedDepartment = department; return View(form); } [HttpPost] public ActionResult Reconfigured(string selectedCompany, string selectedDepartment, string comment) { return RedirectToAction("Index", new { company = selectedCompany, department = selectedDepartment, comment = comment}); } And finally, this is my route: routes.MapRoute( "Default", "{controller}/{company}/{department}", new { controller = "CompanyController", action = "Index", company="", department="" } ); Now, every time I change DropDownList value, all my values are maintained. I end up with a URL like the following after the Reconfigure action is called: http://localhost/Main/Index/Company/Sales?comment=Foo%20Bar Ideally I'd like the URL to remain as: http://localhost/Main/Index My routing object is probably wrong. This can't be the right way? It seems totally wrong to me as for each extra field I add, I have to add the property into the Index() method? I had a look at this answer where the form is passed through TempData. This is obviously an improvement, but it's not strongly typed? Is there a way to do something similar but have it strongly typed? This may be a simple-enough question, but the curse of 10 years of WinForms/WebForms makes this MVC malarky hard to get your head 'round.

    Read the article

  • Is ASP.NET MVC 2.0 released yet?

    - by griegs
    Does anyone know if this has been released yet? I went to asp.net and the Windows PI installs MVC 2 and it doesn't mention anything about RC's but then Scott Guthrie doesn't mention anything on his blog either.

    Read the article

  • asp.net mvc 2 validating text inputs on modal windows

    - by nick
    hi guys, i am tasked with the job of creating client-side validation on a form in an asp.net MVC 2 application, which has a modal window (the modal exists as part of the wrapping form, it is not a form unto itself). how would i go about providing validation for these text field inputs while the modal is visible, but do not validate while the modal is not displayed (as to not cause problems in the rest of the form if the modal window is never required) What is the best approach to achieve this functionality? thanks, Nick

    Read the article

  • Automatically generating better views for ASP.NET MVC

    - by Casebash
    I am currently watching the 80 minute ASP.NET MVC introduction. Automatically generating views from a model is pretty neat, but it seems to me that that the automatically generated views could be much better. For a start, instead of inputing dates with text boxes, there could be a date control. Additionally, number inputs could be verified client side. There are probably other improvements that could be made as well. Is it possible to automatically generate better views?

    Read the article

  • Allowing the specific format of email address in MVC input

    - by user219315
    Hi I have a page in MVC where i want to take the email adddress as the input which can be of format like:"Jone Davi" <[email protected]>, "Ben Miller" <[email protected]>, "Jane Ton" <[email protected]>, Then from this I want to parse the valid emailaddress.But on click of the submit button getting error message" A potentially dangerous Request.Form value was detected from the client " Thus is there any way to take the input of email address in above format and bypass the security error for that specific page. Thanks in advance.

    Read the article

  • ASP.NET MVC form GET passing array

    - by creativeincode
    I have a form with a collection of checkbox's for a refine search function on my website. I am trying to pass an array in a form GET but the URL looks like: /search?filter=foo&filter=bar&filter=green Is there a better way to pass this in MVC? Possible like /search?filter=foo,bar,green Thanks in advance.

    Read the article

  • Trying to create spring project with maven

    - by Gandalf StormCrow
    Hello everyone I was just going trough http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html spring tutorial, and I thought its old I'll think something better on my own. For starters how do I start spring project with maven, which archtype should I choose? I wanna create simple spring app, write class which I will deploy to jboss, spring will instansiate it at startup .. that is what have in mind for now .. for now I need to start it first

    Read the article

  • Spring Security 3 - Login is not working

    - by newbie
    I use Spring Security with Spring Framework 3 and when I tyr to login from homepage I get following error: 2010-04-26 12:16:39,525 [tomcat-http--2] WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/AppName/app/j_spring_security_check] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet' Spring Security is initialized as loggings tell and there are no errors. So what could be reason for this error? I have understood that j_spring_security_check is default url for Spring Security login chekeing servlet.

    Read the article

  • ASP.NET MVC Default URL View

    - by Moose Factory
    I'm trying to set the Default URL of my MVC application to a view within an area of my application. The area is called "Common", the controller "Home" and the view "Index". I've tried setting the defaultUrl in the forms section of web.config to "~/Common/Home/Index" with no success. I've also tried mapping a new route in global.asax, thus: routes.MapRoute( "Area", "{area}/{controller}/{action}/{id}", new { area = "Common", controller = "Home", action = "Index", id = "" } ); Again, to no avail.

    Read the article

  • Alternatives to JSP for Spring MVC view layer

    - by digitaljoel
    I'm looking to create a new app from scratch and will probably use Spring MVC and possibly Spring Web Flow. The projects created by Spring Roo use Spring MVC and optionally Web Flow. What are some good alternatives for view technology, or is JSP with spring and jstl taglibs and jquery the way to go?

    Read the article

  • Sharp Architecture 1.9.5 Released

    - by AlecWhittington
    The S#arp Architecture team is proud to announce the release of version 1.9.5. This version has had the following changes: Upgraded to MVC 3 RTM Solution upgraded to .NET 4 Implementation of IDependencyResolver provided, but not implemented This marks the last scheduled release of 1.X for S#arp Architecture . The team is working hard to get the 2.0 release out the door and we hope to have a preview of that coming soon. With regards to IDependencyResolver, we have provided an implementation, but have...(read more)

    Read the article

  • Class 'org.springframework.http.converter.ResourceHttpMessageConverter' not found - how to correct?

    - by Ash Kim
    Eclipse STS is reporting I have problem with my spring project. It's a fresh project generated from the Spring Web MVC Project Template (File-New-Spring Template Project-Spring Web MVC ). When I create the project it has no problems - it's only once I modify the pom (by adding the hibernate dependencies) that STS then picks up the spring problem. Strangely if I revert the pom the problem remains. Also I can run the project on a spring tc server and all works correctly. Any ideas how I can satisfy this problem report? "Class 'org.springframework.http.converter.ResourceHttpMessageConverter' not found" mvc-config.xml /src/main/webapp/WEB-INF/spring line 9 Spring Beans Problem mvc-config.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <mvc:annotation-driven /> <!-- <= PROBLEMATIC LINE REPORTED BY STS --> <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> </bean> </beans>

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >