partial-views

ASP.Net MVC Passing multiple parameters to a view

In ASP.Net MVC I would like to render a different partial view depending on the renderview query string parameter. Therefore providing the facility for the user to choose to view products by thumbnail or by details. I have access to the chosen parameter in the controller but I do not know how to or, if I should be passing this to the v...

Passing a local variable to a hidden_field in a partial

Hi I am trying to pass these local parameters to a partial form, and they are being passed to hidden_fields. I can't put the values straight into the forms because they will change. Any help would be greatly appreciated. I have: <% form_for :user, @user, :url => { :action => "create", :controller => "users"} do |f| %> <%= f....

Rails nested form using file_field element

I am using code found at Railscast 197 to create nested forms using jQuery. The challenge I am facing is that the nested model uses a file_field element, and because of this when looking at the edit view I just see a list of empty file_field elements. Is there a way I can tell rails to display something else (like a disabled text_field) ...

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

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

Error with strongly-typed partial view when model is a property on a parent model and is null

I am getting the following exception on a call to Html.RenderPartial: The model item passed into the dictionary is of type 'ChildClass' but this dictionary requires a model item of type 'ParentClass'. These two classes are related this: public class ChildClass { /* properties */ } public class ParentClass { public ChildClass ...

Rerendering partial view at a JavaScript event in Ruby on Rails

I would like to rerender some partial views in Ruby on Rails at a specific JavaScript event. Do you guys know how I could do that? More specifically, i have some custom in-place-editor fields (from my own helper based on scriptaculous), and I would like to update some partials whenever new values are submitted on the fields. I do have a...

Get Data To a Shared Partial View

I'm still sadly a bit n00bish when it comes to .NET MVC. I have a navigation partial view being called from a MasterPage where I would like to get a list of data. This partial view is in the "Shared" folder, and thus does not have a controller. How do I get data to it so that it may render a list? Thanks More specifically, I want to do...

How can i return a form using ajax into a view ASP.Net MVC

Hi All, i just started building a small test app to help me learn MVC. i have a view that displays user comments. Under each comment i would like to have a reply action link. Clicking on the link should return a small form for adding a comment directly above the reply link. What is the general approach for this? I'm imaging the form wou...

How can i pass a single string to a partial View from an action that returns the partial view

I am trying to learn MVC, and i'm creating threaded comments functionality for a simple webapp. I have a view which lists the comments, and has a reply button that uses jQuery to load a partial view which is basically a comment form. I need to pass the parent commentId to the partial view and then populate the parentCommentId hiddenfiel...

Mvc RenderPartial to spark view

Sorry if there is another question that covers this. Here is my problem. I am using Html.RenderPartial, i am also using T4MVC. <%Html.RenderPartial(MVC.Shared.Views.MainMenu, Model.Menu); %> spark view: <ul class="menu"> <for each="var menuItem in Menu.ChildItems"> <if condition="menuItem.ChildItems != null"> ...

ASP.NET MVC and strongly-typed partialview

I'm loading a partial view with an AJAX call: public ActionResult LoadServerForm() { //data stuff ViewData["ApplicationID"] = appID.ToString(); ViewData["Servers"] = ServersList(appServerRep.Session, null, appServers); return PartialView("Application_AddServer"); } This ...

Ruby on Rails: conditionally display a partial

I'm not sure if I'm doing the best approach here, but I have a block of data that I want to show after a search is done and to not be there at all before. First of all, there is nothing to show, and second the model it references is nil so it throws an exception. I placed this block in a partial template and added it the appropriate sp...

.NET MVC: How to fix Visual Studio's lack of awareness of CSS classes in partial views?

Hi all, This has been sort of an annoyance for me for a while. I make pretty heavy use of partial views in MVC, and am using Visual Studio 2008 to develop. The problem is that when I give html elements a class in a partial view (<div class="someClass">), it will underline them in green like it doesn't know what they are. I realize this...

Performance impact of wrapping ActionLink extension method inside a partial view

What would be a performance impact if I wrapped every call to an action link (ex. <%=Html.ActionLink(....)) inside a partial view. So in other words instead of calling html extension method for actionlink I would call a html extension method for rendering partial view, and my partialview (user control) would execute the Html.ActionLink(....

Html.ActionLink in Partial View

Hi. I am using the following code in my master page: <% Html.RenderAction("RecentArticles","Article"); %> where the RecentArticles Action (in ArticleController) is : [ChildActionOnly] public ActionResult RecentArticles() { var viewData = articleRepository.GetRecentArticles(3); return PartialView(viewData); ...

ASP.NET MVC Strongly Typed Partial View, gives could not load type error

I am attempting to create a strongly typed view with a "MVC View User Control" that is being rendered using Html.RenderPartial(). The top of my ascx file looks like this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>" %> There is nothing else on this page, currently. When ...

Rendering a derived partial view with Html.RenderPartial

Calling Html.RenderPartial("~/Views/Payments/MyControl.ascx"); from a view works if MyControl.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"); f...

Edit and Create view using EditCreate.ascx partial in ASP.NET MVC

If you look at the NerdDinner example of creating and editing dinners then you see they use a partial (ViewUserControl or ASCX) DinnerForm to put the functionality of creating and editing dinners into one file because it is essential the same and they use it using RenderPartial("DinnerForm"). This approach seems fine for me but I've run...

updating a rails partial with AJAX

I'm new to using AJAX in Rails (I know... I know...), and am positive that I'm doing something wrong that's probably just the wrong call or something. But I've hunted and can't seem to find it. Anyway, I'm rendering out quick partial (this is working right) and then I want to refresh it with an AJAX call. Here's what I thought would wo...

Refresh conent with JQuery/AJAX after using a MVC partial view

Using the following JQuery/AJAX function I'm calling a partial view when an option is changed in a combobox named "ReportedIssue" that is also in the partial view. The is named "tableContent". <script type="text/javascript"> $(function() { $('#ReportedIssue') .change(function() { var styleValue = $(this).va...