partial-views

How to return Nested PartialViews (including their javascript) from an AJAX call in ASP.Net MVC

允我心安 提交于 2019-12-23 20:27:33
问题 I have created a treeview of Categories using nested partial views: my Index page (that displays the treeview): <div> Category Menu: <input type="button" value="1" name='selectCat_btn' /> <input type="button" value="2" name='selectCat_btn' /> </div> <!-- Treeview --> <% Html.RenderPartial("ItemCats_UL", Model); %> <div id="CatSelectorOutput"> </div> ItemCats_UL: <div> <ul id="catsTree"> <% Html.RenderPartial("ItemCats_LI", Model); %> </ul> </div> <script type="text/javascript" > $(document)

MVC Error: model item of type 'System.Collections.Generic.IEnumerable`1 required

时间秒杀一切 提交于 2019-12-23 13:34:11
问题 I'm doing some modifications to a system, and I've run into an exception that I was hoping someone could help with?? The error I'm getting is the following: Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Collections.Generic.List 1[System.String]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable 1[MyApp.Data.aspnet_Users]'. Basically what I want to do is display a list of Inactive users

How to update partial view from another partial view via action results

北城以北 提交于 2019-12-23 12:12:01
问题 I have three partial views on main view on the first partial view I have search functionality and when user clicks on search I want to refresh results into 3rd partial view. Controller: public ActionResult Search() { virtualmodel vm = new virtualmodel(); return PartialView(svm); } [HttpPost] public ActionResult Search(ViewModel svm) { // Query to retrive the result // I am not sure what to return from here. Link to another action or just return back to same same partial } public ActionResult

Partial View in kendo grid column

断了今生、忘了曾经 提交于 2019-12-23 10:53:22
问题 I have an ajax enabled kendo grid with a client template that displays data from the model to which the row is bound. (because of ajax, using columns.Template seems not possible.) @(Html.Kendo().Grid<Model>() .Columns(columns => { columns.Bound(x => x.SubModel).ClientTemplate("bla #= SomePropertyOfSubModel # bla") }) .DataSource(dataSource => dataSource.Ajax()) This works basically, but I am not satisfied with the result. For ex., I have problems to make kendo controls in the template work. I

when should i use partial views in asp.net mvc? [closed]

China☆狼群 提交于 2019-12-23 09:19:59
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I ve gone through sample asp.net mvc nerd dinner application... But still cant understand the point where and when should i go for partial views? Is it similar to usercontrols in webformw? Note: It would be

Using the respond_to method to render a js.erb partial

寵の児 提交于 2019-12-23 04:18:32
问题 I have a feature where users like/unlike and dislike/undislike dishes. This is how I initially have my actions setup: Dishes Controller class DishesController < ApplicationController def like @dish.liked_by current_user end def dislike @dish.disliked_by current_user end ... end Considering the js.erb templates for each template are completely identical I wanted to create just one shared partial that each could use: Original Setup # like.js.erb, unlike.js.erb,dislike.js.erb,undislike.js.erb $(

Register custom control in MVC3 ASPX Partial view

混江龙づ霸主 提交于 2019-12-23 03:39:10
问题 I ask a relevant question here and as I find there is no way to use custom control in Razor views, so I get to add new ASPX partial view to use custom control, my custom control is a dll that I added to References then define Partial view as the following: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %> <%@ Register Assembly="JQControls" Namespace="JQControls" TagPrefix="PersianDatepicker" %> <PersianDatepicker:JQLoader ID="jqdb" runat="server" />

Read image from database and display in view

与世无争的帅哥 提交于 2019-12-23 01:37:08
问题 I'm trying to convert an older ASP.NET application to MVC (I am just learning MVC). and I have a need to display an image in a Gridview. The image itself is stored in a SQL Server table as datatype image. The code that was used previously is below. Can someone suggest an approach using MVC? I was thinking of creating a partial page that I could embed in a standard view, but not sure if that is the right design to implement. Thanks is advance! ` string sqlText = "SELECT * FROM Images WHERE img

How to display Partial view Model errors when partial view is in the view?

大城市里の小女人 提交于 2019-12-23 01:36:15
问题 I am working on the Asp.net Core 2.0 project and have a partial view that is shown in the index view. This partial view have a Model with some validation errors. You can continue to see my Model,Partial view,controller and ... LoginViewModel public class LoginViewModel { [Display(Name = "UserName")] [Required(AllowEmptyStrings = false, ErrorMessage = "Please Enter UserName")] public string UserName { get; set; } [Display(Name = "Password")] [Required(AllowEmptyStrings = false, ErrorMessage =

Rendering view in ASP.Net MVC

久未见 提交于 2019-12-23 00:50:42
问题 In my code I am using a partial view (call it PV1) <div id="div_1"> <% Html.Partial("PV1", Model); %> </div> and in that partial view I am using "Ajax.BeginForm" to redirect it to a particular action, hence it is doing so ... using (Ajax.BeginForm("action1", "Forms", null, new AjaxOptions { UpdateTargetId = "div_1" }, new { id = "form1" })) { Response.write("I am here."); } public ActionResult action1(XYZ Model) { // return PartialView("PV1", Model); } at the last line of action I am again