partial-views

ASP.NET MVC: Is it "wrong" to use HTTP 500 via an AJAX request to return invalid form content?

Here's the situation: I've got two partial views. One has a form. What needs to happen is when the form is posted via an AJAX request, if the operation succeeds, the area with the second partial is repopulated with the content. However, if the posted data was invalid, the original partial is repopulated with an error message. I'm usin...

How to Render Partial View into a String

Hi all, 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...

What does "render @collection" do?

I'm trying to learn Rails better by looking at example applications, and while looking at this line of the source of railscasts.com, I noticed it does this: <div class="episodes"> <%= render @episodes %> </div> What exactly is going on here? Why isn't this documented on the render function? Or is it? ...

Working with partial views

Hi. I'm trying to create a page that contains a grid and searching. The issue is that I want to have a partial view for the grid and one for the searching. If doing a search, this should render the grid partial view with the new information. At the moment I need information, such as what column I'm sorting by and so on, from the grid...

$(document).ready() and partial view load

I am developing an application using Asp.net mvc and jquery. I'd like to use the same naming convention (classes and ids) for html elements in different views. In case when I want to load a partial view asynchronously, the $(document).ready() piece of code in the main view loses its usefulness because none of the patial view's html tag...

Calling a MVC2 partial view using jquery returns empty string problem

I have an issue where I have a partial view that returns some HTML to be displayed. Its called when something is clicked on the page using jquery. The problem is that no matter how I call it, i get back an empty string even though it reports success. This is happening to me using Chrome, going against my local machine. My controller loo...

RoR - Associations into practise - forms (View)

I'm learning Ruby on Rails. I'm using some associations (has_many :through, ...) But i'm having some problems with it when i'm combining my views. How exactly do i combine these nested forms? Can i do this with partial forms and where do i have to write extra code for this? I have seen examples only use the "view" and others also edit...

ASP.NET MVC 2 loading partial view using jQuery - no client side validation

I am using jQuery.load() to render a partial view. This part looks like this: $('#sizeAddHolder').load( '/MyController/MyAction', function () { ... }); The code for actions in my controller is the following: public ActionResult MyAction(byte id) { var model = new MyModel { ObjectPro...

Local variable not being passed to partial template by render?

I don't seem to be able to pass a variable to my partial template in rails (2.3.5). My code is as follows; In the main view .html.erb file: <% f.fields_for :payments do |payment_form| %> <%= render 'payment', {:f => payment_form, :t => "test" } %> <% end %> and in the _payment.html.erb file: <%= t %> produces a wrong number of...

Problems with Partial Views in ASP.NET MVC 2

this is the master page : <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head runat="server"> <title><asp:ContentPlaceHolder ID="TitleContent" runa...

MVC Partial View to Call Display Pop-up window using jquery

Hi I have a index page the renders objects from my database as a treeview, each item has a link href="/MessageGroupType/Edit/1002 that makes an Ajax call to display a partial view in a DIV. Within the partial view there is a delete button which calls my controller to delete the item. However, i do a check to make sure the item can b...

Problem accessing variable in a nested form partial

I have a nested form in a rails view that is called like this <% f.fields_for :invoice_item_numbers do |item_no_form| %> <%= render 'invoice_item_number', :f => item_no_form %> <% end %> and the partial (_invoice_item_number.html.erb) looks like this <div class='invoice_item_numbers'> <% if f.object.new_record? %> <li><%=...

Adding Jquery functionality on PartialView load

How can I attach jquery on an ASP.NET MVC partial load. I've a form rendered in a partial that has some jquery attached, but that code is not running at all ...

Obtain the pathName dynamically for ASP.NET MVC

Hello, I'm looking for a solution that allows me to get the parent page pathname from a partialView invoked. For example I have an Action baa and a controller boo so the javascript to obtain this will be window.location.pathname, and it returns /boo/baa. The thing is that I use a partial view, so when I try to retrieve the pathname v...

Problem showing modelstate errors while using RenderPartialToString

Im using the following code: public string RenderPartialToString(ControllerContext context, string partialViewName, ViewDataDictionary viewData, TempDataDictionary tempData) { ViewEngineResult result = ViewEngines.Engines.FindPartialView(context, partialViewName); if (result.View != null) { Strin...

"partial views" best practices for 'container' divs?

What is the 'best' way to handle the html markup for partial views? (which are also refreshed using AJAX) The biggest issue I run into is where to place the 'container' div... Consider having a masterpage and a partial view. (class="" could be interchanged with id="" depending if the partial is guaranteed to be unique, however this isn'...

Problem Using Partial View In for each loop

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"> ...

Passing ViewData to PartialView returned from using Html.Action

I want to embed a partial view in an ASP.NET MVC page by returning it from an action method. In my base view, I would have: <%= Html.Action("MyPartialViewAction") %> My controller would have an action method like: [ChildActionOnly] public ActionResult MyPartialViewAction() { return PartialView("MyPartialView"); } I expected th...

Rails partial show latest 5 kases

Hi Everyone, I have my application setup with a few different partials working well. I have asked here how to get a partial working to show the latest entry in the kase model, but now I need to show the latest 5 entries in the kase model in a partial. I have duplicated the show most recent one partial and it's working where I need it ...

Pass a variable from view to the layout's partial view

I am trying using a partial to render the application's menu, capitalizing the 'tab' using CSS, based on a local variable (tab): <%= link_to "employees", jobs_path, :class => (tab=="employees" ? "selected":"unselected") %> <a class="unselected">jobs</a> <%= link_to "tags", tags_path, :class => (tab=="tags" ? "selected":"unselected...