partial-views

Disable caching on a partial view in MVC 3

北城余情 提交于 2019-12-18 03:04:42
问题 I have an issue with a partial View being cached when it shouldn't be. This partial View is used to display the Logon/Logoff on a page. It uses the simple code below to figure out which link to display @if(Request.IsAuthenticated) { <a href="@Url.Action("LogOff", "Account", new { area = "" })">Log Off</a> } else { <a href="@Url.Action("LogOn", "Account", new { area = "" })">Log On</a> } This partial View is called from with all pages in my MVC3 application, using @Html.Partial("_HeaderView")

How to handle model state errors in ajax-invoked controller action that returns a PartialView

纵饮孤独 提交于 2019-12-17 21:53:14
问题 I have a POST controller action that returns a partial view. Everything seems really easy. but. I load it using $.ajax() , setting type as html . But when my model validation fails I thought I should just throw an error with model state errors. But my reply always returns 500 Server error. How can I report back model state errors without returning Json with whatever result. I would still like to return partial view that I can directly append to some HTML element. Edit I would also like to

Ajax call in rails 3.2.3 with will_paginate gem

时间秒杀一切 提交于 2019-12-17 19:26:42
问题 Im trying to implement an Ajax call with the will_paginate gem, I found this guide http://ramblinglabs.com/blog/2011/11/rails-3-1-will_paginate-and-ajax which seemed like a simple solution, though it includes coffeescript which i am not familiar with, so if anyone has a different solution then please advise.. My code is as follows My View <div class="container"> <div class="row"> <div id="userRecipes"> <%= render partial: 'userrecipes' %> </div> </div><!--/row--> My partial (userrecipes) <%

PHP Mustache 2.1 partial loading NOT based on the filename

删除回忆录丶 提交于 2019-12-17 19:04:05
问题 Is there a way to load partials based on an array of filename values? Currently if I write this {{> sidebar}} it will look for views/sidebar.mustache . (based on the template loader class where I can specify where to look for the templates) Ideally I want that {{> sidebar}} would be a variable name and not a file name. What I want to achieve is to look for the sidebar partial not based on the filename, if I pass to the loader: $partials = array( 'sidebar' => 'folder1/somefile' ); which would

Updating partial view with Jquery in ASP.NET MVC C#

∥☆過路亽.° 提交于 2019-12-17 18:41:01
问题 I am using MVC C# along with Jquery. I have a partial view in a rather large page that has a number of tabs. On a click of a checkbox, I like to update the partial view WITHIN the form. What I am getting instead is just the partial view Here is my code in Jquery: $('#activelist,#inactivelist').change(function () { var status = 'inactive'; window.location.href = '@Url.Action("Skits","KitSection")' + '?id=' + id+ '&status=' + status; }); Any idea on how I could update the partial view within a

Unobtrusive validation not working on dynamically-added partial view

心已入冬 提交于 2019-12-17 05:40:53
问题 I am currently facing a problem with validation after dynamically adding content. I have a view strongly typed to a model ( Order ). This Order can have many items. The model looks something like the following: public class Order { [Key] [HiddenInput] public int id { get; set; } [Display(Name = "Order Number")] public string number { get; set; } [Display(Name = "Order Date")] [DataType(DataType.Date)] [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")] public

Rails: confused about syntax for passing locals to partials

夙愿已清 提交于 2019-12-17 02:58:09
问题 Understanding Rails "magic" with regards to rendering partials (and passing locals into them). Why does this work: <%= render "rabbits/form" %> And this work: <%= render "rabbits/form", :parent => @warren, :flash => flash %> but this does not work: <%= render "rabbits/form", :locals => { :parent => @warren, :flash => flash } %> But this does: <%= render :partial =>"rabbits/form", :locals => { :parent => @warren, :flash => flash } %> Also, how can I look up these nuances so I don't need to

How to Render Partial View into a String

99封情书 提交于 2019-12-17 02:12:17
问题 I have the following code: public ActionResult SomeAction() { return new JsonpResult { Data = new { Widget = "some partial html for the widget" } }; } I'd like to modify it so that I could have public ActionResult SomeAction() { // will render HTML that I can pass to the JSONP result to return. var partial = RenderPartial(viewModel); return new JsonpResult { Data = new { Widget = partial } }; } is this possible? Could somebody explain how? note , I edited the question before posting the

Problem Using Partial View In for each loop

时光怂恿深爱的人放手 提交于 2019-12-14 03:58:13
问题 I'm a little confused here, I am trying use a partial view in a for each loop like so <% foreach (var item in (IEnumerable<MVCLD.Models.Article>)ViewData["LatestWebsites"]){%> <% Html.RenderPartial("articlelisttemaple", item); %> <% } %> And my partial view looks like this <div class="listingholders"> <h4><%=Html.ActionLink(item.ArticleTitle, "details", "article", new { UrlID = item.UrlID, ArticleName = item.ArticleTitle.ToString().niceurl() }, null)%> </h4> <p><%= Html.Encode(item

MVC3 Multiple PartialViews in one View

孤者浪人 提交于 2019-12-14 03:09:42
问题 The answer supplied here is exactly what i've got going on. But when I hit submit in either partialview, the output is just the html for the PartialView! I'm new to MVC3 so I'm sure I'm just missing something that I should have already learned. public ActionResult CreateV2Worksheet() { return PartialView("_NewV2WorksheetInput", new NewV2WorksheetInputModel()); } [HttpPost] public ActionResult CreateV2Worksheet(NewV2WorksheetInputModel pNewV2Input) { if (ModelState.IsValid) { ModelState