Search Results

Search found 16291 results on 652 pages for 'mvc helper controls'.

Page 15/652 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • MVC or Extract Service Layer

    - by Lizzard
    we have an application that is built with .Net MVC. We are now tasked with exposing API's to third parties. Members on our team want to just continue down our current path and just use more controllers so we can reuse the backend of our current application. Logic tells me we need to create a seperate service layer when more clients are going to be accessing it, but .Net MVC seems to take care of all of this. Is it really acceptable architecture to use controllers in a stand alone application to expose API's and what would be the potential gains of extracting the service layer out?

    Read the article

  • Email as a view.

    - by Hal
    I've been in some discussion recently about where email (notifications, etc...) should be sent in an ASP.NET MVC application. My nemesis grin argues that it only makes sense that the email should be sent from the controller. I argue that an email is simply an alternate or augmented view through a different channel. Much like I would download a file as the payload of an ActionResult, the email is simply delivered through a different protocol. I've worked an extension method that allows me to do the following: <% Html.RenderEmail(model.FromAddress, model.ToAddress, model.Subject); %> which I actually include within my the view that is displayed on the screen. The beauty is that, based on convention, if I call RenderEmail from a parent view named MyView.ascx, I attempt to render the contents of a view named MyViewEmail.ascx, unless it is not found, in which case I simply email a copy of parent view. It certainly does make it testable (I still have an ISMTPService injected for testing), I wondered if anyone had any thoughts on whether or not this breaks from good practice. In use it has been extremely handy when we needed to easily send an email or modify the contents of the emailed results vs the browser rendered results. Thanks, Hal

    Read the article

  • asp.net mvc 2 EditorFor() and html properties

    - by chandmk
    Asp.Net MVC 2.0 preview builds provide helpers like Html.EditorFor(c => c.propertyname) If the property name is string, the above code renders a texbox. What if I want to pass in MaxLength and Size properties to the text box or my own css class property? Do I need to create one template for each size and length combinations in my application? If so, that doesn't make the default templates that usable.

    Read the article

  • 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

  • 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

  • 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

  • Need to replace 3rd party WinForm controls, what's the closet WPF equivalent?

    - by Refracted Paladin
    I am tired of Windows Forms...I just am. I am not trying to start a debate on it I am just bored with it. Unfortunately we have become dependent on 4 controls in DevExpress XtraEditors. I have had nothing but difficulties with them and I want to move on. What I need now is what the closet replacement would be for the 4 controls I am using. Here they are: LookUpEdit - this is a dropdown that filters the dropdown list as you type. MemoExEdit - this is a textbox that 'pops up' a bigger area when it has focus CheckedComboBoxEdit - this is a dropdown of checkboxes. CheckedListBoxControl - this is a nicely columned list box of checkboxes This is a LOB app that has tons of data entry. In reality, the first two are nice but not essential. The second two are essential in that I would either need to replicate the functionality or change the way the users are interacting with that particular data. I am looking for help in replicating these in a WPF environment with existing controls(codeplex etc) or in straight XAML. Any code or direction would be greatly appreciated but mostly I am hoping to avoid any commercial 3rd party WPF and would instead like to focus on building them myself(but I need direction) or using Codeplex

    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

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >