Search Results

Search found 129 results on 6 pages for 'renderpartial'.

Page 1/6 | 1 2 3 4 5 6  | Next Page >

  • RenderPartial a view from another controller (and in another folder)

    - by George
    Hey MVC experts. I two database entities that i need to represent and i need to output them in a single page. I have something like this Views Def ViewA ViewB Test ViewC I want to ViewC to display ViewA, which displays ViewB. Right now i'm using something like this: // View C <!-- bla --> <% Html.RenderPartial(Url.Content("../Definition/DefinitionDetails"), i); %> // View A <!-- bla --> <% Html.RenderPartial(Url.Content("../Definition/DefinitionEditActions")); %> Is there a better to do this? I find that linking with relative pathnames can burn you. Any tips? Any chance I can make somehtiing like... Html.RenderPartial("Definition","DefinitionDetails",i); ? Thanks for the help

    Read the article

  • Rendering a derived partial view with Html.RenderPartial

    - by FreshCode
    Calling Html.RenderPartial("~/Views/Payments/MyControl.ascx"); from a view works if Method.ascx is a control that directly inherits System.Web.Mvc.ViewUserControl. However, if the control inherits a new class that derives from System.Web.Mvc.ViewUserControl, the call to Html.RenderPartial("~/Views/Payments/MyDerivedControl.ascx"); fails, reporting that no such view exists. Example derived ViewUserControl: class MyDerivedControl : System.Web.Mvc.ViewUserControl { public Method() { ViewData["SomeData"] = "test"; } } Is there a workaround, or is there another way I should be doing this? Perhaps an HTML helper?

    Read the article

  • passing parameters to .aspx page using renderpartial

    - by dexter
    in my index.aspx page i want to render another module.aspx page using renderpartial which then render a .htm file depanding on which parameter is passed from index.aspx (it would be number ie 1,2 etc ,so as to call different different .htm file everytime depending on the parameter) 1). now i want Index.aspx page to render module.aspx and pass it a parameter(1,2,3,etc) [the parameters would be passed programatically (hardcoded)] and 2). mudule.aspx should catch the parameter and depending on it will call .htm file my index.aspx has <% ViewData["TemplateId"] = 1; %> <% Html.RenderPartial("/Views/Templates/MyModule.aspx", ViewData["TemplateId"]); %> and module.aspx contains <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <script type="text/javascript" src="/Scripts/jquery-1.3.2.js"></script> <script type="text/javascript" src="/Scripts/Service.js"></script> <script type="text/javascript"> debugger; var tid = '<%=ViewData["TemplateId"] %>'; $.get("/Templates/Select/" + tid, function(result) { $("#datashow").html(result); }); </script> <div id="datashow"></div> this is my controller which is called by $.get(....) (see code) public ActionResult Select(int id) { return File("/Views/Templates/HTML_Temp" +id.ToString()+".htm" , "text/html"); } and finally my .htm file <div id="divdata" class="sys-template"> <p>Event Title:<input id="title" size="150" type="text" style="background-color:yellow;font-size:25px;width: 637px;" readonly="readonly" value="{{title}}" /> </p> <p>Event Description:<input type="text" id="description" value="{{ description }}" readonly="readonly" style="width: 312px" /></p> <p>Event Date: <input type="text" id="date" value="{{ date }}" readonly="readonly" style="width: 251px"/></p> <p>Keywords : <input type="text" id="keywords" value="{{keywords}}" readonly="readonly" /></p> </div> <script type="text/javascript"> Sys.Application.add_init(appInit); function appInit() { start(); } </script> start() is javascript method which is in file Service.js when i run this programm it gives me error js runtime error: 'object expected' and debugger highlighted on <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/**xhtml**1-strict.dtd"> pls help me solve the problem

    Read the article

  • Renderpartial or renderaction

    - by femi
    have an action that generates active vacancies. The code is below; public ViewResult OpenVacancies() { var openvacancies = db.GetActiveVacancies(); return View(openvacancies); } I want to use this list on several pages so i guess the best thing to use is html.renderaction (please correct me if i am wrong here). Please note that the view and .ascx control are in an Area. I then created a view by right clicking inside the action and create a .ascx and a strongly typed view of Vacancy. I chose a view content of "List". I then added this line to the required page; <% Html.RenderAction("OpenVacancies"); % Please note that the view and .ascx control are in an Area. The error i got is; The type or namespace name 'Vacancy' could not be found (are you missing a using directive or an assembly reference?) the .ascx code is below; <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" % <table> <tr> <th></th> <th> VacancyID </th> <th> JobTitle </th> <th> PositionID </th> <th> LocationID </th> <th> JobDescription </th> <th> JobConditions </th> <th> Qualifications </th> <th> RequiredSkills </th> <th> Certifications </th> <th> AdvertDate </th> <th> AdvertExpiryDate </th> <th> Status </th> <th> StaffLevel </th> <th> LineManagerEmail </th> <th> ApprovalFlag </th> <th> RequisitionDate </th> </tr> <% foreach (var item in Model) { %> <tr> <td> <%= Html.ActionLink("Edit", "Edit", new { id=item.VacancyID }) %> | <%= Html.ActionLink("Details", "Details", new { id=item.VacancyID })%> | <%= Html.ActionLink("Delete", "Delete", new { id=item.VacancyID })%> </td> <td> <%= Html.Encode(item.VacancyID) %> </td> <td> <%= Html.Encode(item.JobTitle) %> </td> <td> <%= Html.Encode(item.PositionID) %> </td> <td> <%= Html.Encode(item.LocationID) %> </td> <td> <%= Html.Encode(item.JobDescription) %> </td> <td> <%= Html.Encode(item.JobConditions) %> </td> <td> <%= Html.Encode(item.Qualifications) %> </td> <td> <%= Html.Encode(item.RequiredSkills) %> </td> <td> <%= Html.Encode(item.Certifications) %> </td> <td> <%= Html.Encode(String.Format("{0:g}", item.AdvertDate)) %> </td> <td> <%= Html.Encode(String.Format("{0:g}", item.AdvertExpiryDate)) %> </td> <td> <%= Html.Encode(item.Status) %> </td> <td> <%= Html.Encode(item.StaffLevel) %> </td> <td> <%= Html.Encode(item.LineManagerEmail) %> </td> <td> <%= Html.Encode(item.ApprovalFlag) %> </td> <td> <%= Html.Encode(String.Format("{0:g}", item.RequisitionDate)) %> </td> </tr> <% } %> </table> <p> <%= Html.ActionLink("Create New", "Create") %> </p>

    Read the article

  • asp.net-mvc RenderPartial onclick

    - by niao
    Greetings, I have an asp.net mvc application. I have some links that corresponds to clients names. When user clicks on this link I would like to show an information of clicked client and additionally a textarea where user shall be able to write some text (comment) about selected client. How can I achieve it?

    Read the article

  • Broken RenderPartial After Upgrade To ASP.NET MVC2

    - by mxmissile
    I upgraded a MVC1 project to MVC2, now all my calls to RenderPartial are throwing System.ArgumentNullException: Value cannot be null. However this does works: <% Html.RenderPartial("~/Views/Shared/LogOnUserControl.ascx"); %> And this does not (works in MVC1): <% Html.RenderPartial("LogOnUserControl"); %> Did the behavior of RenderPartial change?

    Read the article

  • What is the difference (if any) between Html.Partial(view, model) and Html.RenderPartial(view,model)

    - by Stephane
    Other than the type it returns and the fact that you call it differently of course <% Html.RenderPartial(...); %> <%= Html.Partial(...) %> If they are different, why would you call one rather than the other one? The definitions: // Type: System.Web.Mvc.Html.RenderPartialExtensions // Assembly: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // Assembly location: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll using System.Web.Mvc; namespace System.Web.Mvc.Html { public static class RenderPartialExtensions { public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName); public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName, ViewDataDictionary viewData); public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName, object model); public static void RenderPartial(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary viewData); } } // Type: System.Web.Mvc.Html.PartialExtensions // Assembly: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // Assembly location: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll using System.Web.Mvc; namespace System.Web.Mvc.Html { public static class PartialExtensions { public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName); public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, ViewDataDictionary viewData); public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, object model); public static MvcHtmlString Partial(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary viewData); } }

    Read the article

  • asp.net MVC RC1 RenderPartial ViewDataDictionary

    - by Mark79
    I'm trying to pass a ViewData object from a master page to a view user control using the ViewDataDictionary. The problem is the ViewDataDictionary is not returning any values in the view user control whichever way i try it. The sample code below is using an anonymous object just for demonstration although neither this method or passing a ViewData object works. Following is the RenderPartial helper method i'm trying to use: <% Html.RenderPartial("/Views/Project/Projects.ascx", ViewData.Eval("Projects"), new ViewDataDictionary(new { Test = "Mark" })); %> and in my view user control i do the following: <%= Html.Encode(ViewData["Test"]) %> Why does this not return anything? Thanks for your help. EDIT: I'm able to pass and access the stronlgy typed model without any problems. it's the ViewDataDictionary which i'm trying to use to pass say just a single value outside of the model..

    Read the article

  • RenderPartial from different folder in RAZOR

    - by Dien
    I've been trying to convert my aspx pages to cshtml and having an issue with rendering partial pages from another folder. What I used to do: <% Html.RenderPartial("~/Views/Inquiry/InquiryList.ascx", Model.InquiryList.OrderBy("InquiryId", MvcContrib.Sorting.SortDirection.Descending));%> I would think that the equivalent would be: @Html.RenderPartial("~/Views/Inquiry/_InquiryList.cshtml", Model.InquiryList.OrderBy("InquiryId", MvcContrib.Sorting.SortDirection.Descending)) This is obviously not working, I am getting the following error. CS1973: 'System.Web.Mvc.HtmlHelper' has no applicable method named 'Partial' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax. How would I achieve this with using the Razor view engine?

    Read the article

  • ASP.NET MVC 1.0: OutputCache, RenderPartial and WriteSubstitution

    - by David
    Hi folks, after digging into this topic and having the requirement, that a single page should be totally cached, except for a Html.RenderPartial("LogOnUserControl"); i couldn't find any working solution on this... the only "it getting warmer" thing i foudn was this solution , which unfortunately is not working with a "partial view", which requires the Request.IsAuthenticated attribute ( the fakeContext is losing this info ) Have you heard of any other solution to do this?!

    Read the article

  • RenderPartial missing from Html Helper in ASP.NET MVC 2

    - by Guy
    I've just converted an application from MVC 1 to MVC 2 using the VS2010 wizard. Not found is the Html.RenderPartial which I have sprinkled around a number of views. I am guessing that this is something that I've done wrong because I see no mention of this as a breaking change in the white papers and docs. Everything I'm using is RTM/RTW and no beta or RC versions.

    Read the article

  • .net MVC RenderPartial renders information that is not in the model

    - by Andreas
    Hi, I have a usercontrol that is rendering a list of items. Each row contains a unique id in a hidden field, a text and a delete button. When clicking on the delete button I use jquery ajax to call the controller method DeleteCA (seen below). DeleteCA returns a new list of items that replaces the old list. [HttpPost] public PartialViewResult DeleteCA(CAsViewModel CAs, Guid CAIdToDelete) { int indexToRemove = CAs.CAList.IndexOf(CAs.CAList.Single(m => m.Id == CAIdToDelete)); CAs.CAList.RemoveAt(indexToRemove); return PartialView("EditorTemplates/CAs", CAs); } I have checked that DeleteCA is really removing the correct item. The modified list of CAs passed to PartialView no longer contains the deleted item. Something weird happens when the partial view is rendered. The number of items in the list is reduced but it is always the last element that is removed from the list. The rendered items does not correspond to the items in the list/model sent to PartialView. In the usercontrol file (ascx) I'm using both Model.CAList and lambda expression m = m.CAList. How is it possible for the usercontrol to render stuff that is not in the model sent to PartialView? Thanx Andreas

    Read the article

  • Trying to pass Model down to partial, how do I do this?

    - by mrblah
    My action creates a strongly typed viewdata, which is passed to my view. In the view, I pass the Model to the render partial method. public ActionResult Index() { ViewDataForIndex vd = new ViewDataForIndex(); vd.Users = Users.GetAll(); return View(vd); } public class ViewDataForIndex: ViewData { public IList<User> Users {get;set;} } now in the view: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ViewDataForIndex>" %> <% Html.RenderPartial("~/controls/blah.ascx", ViewData.Model); %> and in blah.ascx: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> how do I access my model now? if I wanted to create a strongly typed class for my ViewUserControl, how would I do that? inherit from?

    Read the article

  • jQuery partial page refresh after form submit

    - by heeboir
    When using jQuery to submit a form is it possible to place the resulting page (after the submit) inside another HTML element? I'll try to make this clearer. Up to now I've been using Callback methods that among others do a document.forms['form'].submit(); whenever a form has been updated with new information and needs to be refreshed. However, this results in a full page refresh. I'm implementing Partial Page Refresh using jQuery and thought of using something like var newContent = jQuery('#form').submit(); jQuery('#div').load(newContent); However, that does not seem to work as the page is still fully refreshed. The content is correct, however the behaviour seems to be exactly the same as before - so I'm not really sure if what I want is actually possible with jQuery. Any hints and pointers would be helpful. Thanks.

    Read the article

  • Page doesn't un-cache itself in ASP.NET C#

    - by waqasahmed
    Hi, I sometimes find that I need to press CTRL+REFRESH BUTTON (or simply REFRESH BUTTON) in order for pages to be updated. I thought this may have been a problem with using AJAX Update Panel and things, but it also happens on pages where there is no AJAX partial rendering. I have also removed if(!isPostBack), and yet still I need to refresh the page for the contents to be updated. Is it to do with the cache? Does anyone know of a fix for this? I believe it only happens with IE 7 (which I am using). I tried the same feature with Chrome, and it worked as it is supposed to.

    Read the article

  • AJAX Partial Rendering issues for the default page in IIS 7 when using custom http module

    - by WiseGuyEh
    The problem When I try to make a AJAX partial update request (using the UpdatePanel control) from the default page of an IIS7 web site, it fails- instead of returning the html to be updated, it returns the entire page, which then causes the MS AJAX Javascript to throw a parsing shit-fit. The suspected cause I have narrowed the cause down to two issues- making an AJAX request to the default page when I have a certain custom http module registered. A partial rendering request to http://localhost will fail, but a partial rendering request to http://localhost/default.aspx will work fine. Also, If i remove the following line in my custom HttpModule: _application.PreRequestHandlerExecute += OnPreRequestHandlerExecute; The AJAX partial render will work correctly. Wierd huh? Another wierd thing... If I look at trace.axd, I can see that when a partial rendering request fails, two POST requests are logged for the one partial rendering request- one where the default.aspx page executes successfully (trace information such as page_load is logged) but no content is produced and a second that doesn't seem to actually execute (no trace information is logged) but produces content (HTTP_CONTENT_LENGTH is greater than 0). Please help! If anyone with a good knowledge of HTTP modules or the MS AJAX Http module could explain why this is occuring I would be very grateful. As it is, the obvious work arround is to just redirect to default.aspx if the request url is "/" but I would really like to understand why this is occurring.

    Read the article

  • Design pattern to integrate Rails with a Comet server

    - by empire29
    I have a Ruby on Rails (2.3.5) application and an APE (Ajax Push Engine) server. When records are created within the Rails application, i need to push the new record out on applicable channels to the APE server. Records can be created in the rails app by the traditional path through the controller's create action, or it can be created by several event machines that are constantly monitoring various inputstream and creating records when they see data that meets a certain criteria. It seems to me that the best/right place to put the code that pushes the data out to the APE server (which in turn pushes it out to the clients) is in the Model's after_create hook (since not all record creations will flow through the controller's create action). The final caveat is I want to push a piece of formatted HTML out to the APE server (rather than a JSON representation of the data). The reason I want to do this is 1) I already have logic to produce the desired layout in existing partials 2) I don't want to create a javascript implementation of the partials (javascript that takes a JSON object and creates all the HTML around it for presentation). This would quickly become a maintenance nightmare. The problem with this is it would require "rendering" partials from within the Model (which im having trouble doing anyhow because they don't seem to have access to Helpers when they're rendered in this manner). Anyhow - Just wondering what the right way to go about organizing all of this is. Thanks

    Read the article

  • Asp.net MVC jquery-ajax dont render html

    - by Troublesum
    Hi, Im trying to use jqeury ajax with MVC i can get it to post back to the action i want and it returns the ViewData objects with updated Data but never renders the HTML. I have i View which contains some MVC User Controls and i want them to update on a timer. Here is my View Markup <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/PageWithSummaryViewAndTabs.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="FullCaseTitle" ContentPlaceHolderID="TitleContent" runat="server"> </asp:Content> <asp:Content ID="FullCaseContent" ContentPlaceHolderID="MainContent" runat="server"> <script type="text/javascript"> window.setInterval(test, 5000); function test() { jQuery.get("/PatientCase/RefreshEPRF", function(response) { }); } </script> <div id="loadingDiv" style="display:none">Updating</div> <input id="refreshPatientCaseIndexButton" type="submit" visible="true" title="refresh" value="Refresh" /> <h2>Full Case</h2> <div id="EPRFContent"> <%Html.RenderPartial(@"~/Views/PatientCase/SectionEPRF.ascx"); %> <%Html.RenderPartial(@"~/Views/PatientCase/SectionDrugs.ascx"); %> </div> <div id="ImageContent"> <%Html.RenderPartial(@"~/Views/PatientCase/SectionImagery.ascx"); % On postback i call a Action Called RefreshEPRF which loads just the required user controls again <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%Html.RenderPartial(@"~/Views/PatientCase/SectionEPRF.ascx"); %> <%Html.RenderPartial(@"~/Views/PatientCase/SectionDrugs.ascx"); %> And finaly the marpup in the control <table id="detailstable"> <tr><td id="detailslablecolumn">Patient Name : </td><td> <% foreach (var item in (List<STS_Lite.Models.PatinetCase.EPRFItem>)ViewData["EPRF"]) { if (item.datumItemId == 46) { if (item.Stroke) { %> <img src="/PatientCaseIndex/InkImageData/GetInkImage/<%=ViewData["PatientCaseId"]%>/<%=ViewData["TemplateInstanceId"]%>/<%=item.TemplateItemId %>" /> <% } else {%> <%=item.Value.ToString()%> <%} break; } } %></td></tr><table> When i step through this code the ViewData in the user control has the new updated values but the page comes back with no new values. I have tried the jquery.get and ajax but with no luck. Any help would be great thanks

    Read the article

  • Tabs in asp.net mvc

    - by Xulfee
    I have three tabs on page and one user control. I want to RenderPartial on each tab. <script type="text/javascript"> $(document).ready(function() { $("#tabs").tabs(); }); </script> <div id="tabs"> <ul> <li><a href="#tabs-1">Text 1</a></li> <li><a href="#tabs-2">Text 2</a></li> <li><a href="#tabs-3">Text 3</a></li> </ul> <div id="tabs-1"> <% Html.RenderPartial("usercontrol", Model); %> </div> <div id="tabs-2"> <% Html.RenderPartial("usercontrol", Model); %> </div> <div id="tabs-3"> <% Html.RenderPartial("usercontrol", Model); %> </div> </div> how can i get values from different tabs.

    Read the article

  • how do you reuse a partial view with setting different ids

    - by oo
    i have a partial view with a dropdown in it. the code looks like this: <%=Html.DropDownListFor(x => Model.Exercises, new SelectList(Model.Exercises, "Id", "Name", Model.SelectedExercise), new { @id = "exerciseDropdown", @class = "autoComplete" })%> the issue is that i want to reuse this partial view in multiple places but i want to have a different id assigned to the control (instead of exerciseDropdown always) but on the outside i only have this . . <% Html.RenderPartial("ExerciseList", Model); %> is there anyway to pass in an id into a partial view. is there a standard way to inject the ids into a partial view ? right now i am doing things like this: <% Html.RenderPartial("ExerciseList", Model); %> <% Html.RenderPartial("ExerciseList2", Model); %> where ExerciseList and ExerciseList2 are identical but with different ids but i am sure there is a better way.

    Read the article

  • How to write submit form in another manner?

    - by user281180
    I have the follwing: <% using (Ajax.BeginForm("ChangePassword", new AjaxOptions { OnComplete = "ChangePasswordComplete" })) {% <%Html.RenderPartial("ChangePassword"); % <input type="submit" value="test" /> <%} % I want to write it in the following manner: <form> <%Html.RenderPartial("ChangePassword"); %> <input type="submit" value="test" /> </form> How can I do that? What to write in the form tag

    Read the article

  • Hello, T4MVC &ndash; Goodbye, ASP.NET MVC &ldquo;magic strings&rdquo;

    - by Brian Schroer
    I’m working on my first ASP.NET MVC project, and I really, really like MVC. I hate all of the “magic strings”, though: <div id="logindisplay"> <% Html.RenderPartial("LogOnUserControl"); %> </div> <div id="menucontainer"> <ul id="menu"> <li><%=Html.ActionLink("Find Dinner", "Index", "Dinners")%></li> <li><%=Html.ActionLink("Host Dinner", "Create", "Dinners")%></li> <li><%=Html.ActionLink("About", "About", "Home")%></li> </ul> </div> They’re prone to misspelling (causing errors that won’t be caught until runtime), there’s duplication, there’s no Intellisense, and they’re not friendly to refactoring tools.   I had started down the path of creating static classes with constants for the strings, e.g.: <li><%=Html.ActionLink("Find Dinner", DinnerControllerActions.Index, Controllers.Dinner)%></li> …but that was pretty tedious.   Then I discovered T4MVC (http://mvccontrib.codeplex.com/wikipage?title=T4MVC). Just add its T4MVC.tt and T4MVC.settings.t4 files to the root of your MVC application, and it magically (and this time, it’s good magic) generates code that allows you to replace the first code sample above with this: <div id="logindisplay"> <% Html.RenderPartial(MVC.Shared.Views.LogOnUserControl); %> </div> <div id="menucontainer"> <ul id="menu"> <li><%=Html.ActionLink("Find Dinner", MVC.Dinners.Index())%></li> <li><%=Html.ActionLink("Host Dinner", MVC.Dinners.Create())%></li> <li><%=Html.ActionLink("About", MVC.Home.About())%></li> </ul> </div> It gives you a strongly-typed alternative to magic strings for all of these scenarios: Html.Action Html.ActionLink Html.RenderAction Html.RenderPartial Html.BeginForm Url.Action Ajax.ActionLink view names inside controllers But wait, there’s more! It even gives you static helpers for image and script links, e.g.: <img src="<%= Links.Content.nerd_jpg %>" />   <script src="<%= Links.Scripts.Map_js %>" type="text/javascript"></script> …instead of: <img src="/Content/nerd.jpg" />   <script src="/Scripts/Map.js" type="text/javascript"></script>   Thanks to David Ebbo for creating this great tool. You can watch an eight and a half minute video about T4MVC on Channel 9 via this link: http://channel9.msdn.com/posts/jongalloway/Jon-Takes-Five-with-David-Ebbo-on-T4MVC/. You can download T4MVC from its CodePlex page: http://mvccontrib.codeplex.com/wikipage?title=T4MVC.

    Read the article

  • How to check if returning View is of type PartialViewResult or a ViewUserControl

    - by mare
    In the method FindView() I have to somehow check if the View we are requesting is a ViewUserControl. Because otherwise I get an error saying: "A master name cannot be specified when the view is a ViewUserControl." This is my custom view engine code right now: public class PendingViewEngine : VirtualPathProviderViewEngine { public PendingViewEngine() { // This is where we tell MVC where to look for our files. /* {0} = view name or master page name * {1} = controller name */ MasterLocationFormats = new[] {"~/Views/Shared/{0}.master", "~/Views/{0}.master"}; ViewLocationFormats = new[] { "~/Views/{1}/{0}.aspx", "~/Views/Shared/{0}.aspx", "~/Views/Shared/{0}.ascx", "~/Views/{1}/{0}.ascx" }; PartialViewLocationFormats = new[] {"~/Views/{1}/{0}.ascx", "~/Views/Shared/{0}.ascx"}; } protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) { return new WebFormView(partialPath, ""); } protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) { return new WebFormView(viewPath, masterPath); // this line produces the error because we cannot set master page on ASCXs, so I need an "if" here } public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { if (controllerContext.HttpContext.Request.IsAjaxRequest()) return base.FindView(controllerContext, viewName, "Modal", useCache); return base.FindView(controllerContext, viewName, "Site", useCache); } } The above ViewEngine fails on calls like this: <% Html.RenderAction("Display", "MyController", new { zoneslug = "some-zone-slug" });%> The action I am rendering here is this: public ActionResult Display(string zoneslug) { WidgetZone zone; if (!_repository.IsUniqueSlug(zoneslug)) zone = (WidgetZone) _repository.GetInstance(zoneslug); else { // do something here } // WidgetZone used here is WidgetZone.ascx, so a partial return View("WidgetZone", zone); } I cannot use RenderPartial because you cannot send route values to RenderPartial the way you can to RenderAction. To my knowledge there is no way to provide RouteValueDictionary to RenderPartial() like the way you can to RenderAction().

    Read the article

  • Determining which form input failed validation?

    - by Alastair Pitts
    I am designing a creation wizard in ASP.NET MVC 1 and instead of posting back each step, I'm using javascript to toggle the display of the different steps divs. This is a quick sample of the code, just to explain. <% using (Html.BeginForm()) {%> <fieldset> <legend>Fields</legend> <div id="wizardStep1"> <% Html.RenderPartial("CreateStep1", Model); %> </div> <div id="wizardStep2"> <% Html.RenderPartial("CreateStep2", Model); %> </div> <div id="wizardStep3"> <% Html.RenderPartial("CreateStep3", Model); %> </div> </fieldset> <% } %> I have javascript that just toggles the visibility of the divs, with each partial view containing a different section of the input form (which is pretty large by itself) My question is, if the form fails validation and I reload the page with the validation errors, is there a way for me to determine which div contains the error? Either in javascript or other? Failing that, is there a good client-side validation library for MVC 1? Ideally I'd love to move to MVC2 and the client side validation built into that, but I am required to use MVC1

    Read the article

1 2 3 4 5 6  | Next Page >