Search Results

Search found 117 results on 5 pages for 'partialview'.

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

  • ASP.NET MVC - Refresh PartialView when DropDownList changed

    - by Bryan Roth
    I have a search form that is an Ajax form. Within the form is a DropDownList that, when changed, should refresh a PartialView within the Ajax form (via a GET request). However, I'm not sure what to do in order to refresh the PartialView after I get back my results via the GET request. Search.aspx <%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Search </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <script type="text/javascript"> $(document).ready(function () { $("#Sections").change(function () { var section = $("#Sections").val(); var township = $("#Townships").val(); var range = $("#Ranges").val(); $.ajax({ type: "GET", url: "Search/Search?section=" + section + "&township=" + township + "&range=" + range, contentType: "application/json; charset=utf-8", dataType: "html", success: function (result) { // What should I do here to refresh PartialView? } }); }); }); </script> <h2>Search</h2> <%--The line below is a workaround for a VB / ASPX designer bug--%> <%=""%> <% Using Ajax.BeginForm("Search", New AjaxOptions With {.UpdateTargetId = "searchResults", .LoadingElementId = "loader"})%> Township <%= Html.DropDownList("Townships")%> Range <%= Html.DropDownList("Ranges")%> Section <%= Html.DropDownList("Sections")%> <% Html.RenderPartial("Corners")%> <input type="submit" value="Search" /> <span id="loader">Searching...</span> <% End Using%> <div id="searchResults"></div> </asp:Content>

    Read the article

  • ASP.NET MVC - PartialView html not changing via jQuery html() call

    - by Bryan Roth
    When I change the selection in a DropDownList, a PartialView gets updated via a GET request. When updating the PartialView via the jQuery html() function, the html returned is correct but when it displayed in the browser it is not correct. For example, certain checkboxes within the PartialView should become enabled but they remain disabled even though the html returned says they should be. When I do a view source in the browser the html never gets updated. I'm a little perplexed. Thoughts? Search.aspx <%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Search </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <script type="text/javascript"> $(document).ready(function () { $("#Sections").change(function () { var section = $("#Sections").val(); var township = $("#Townships").val(); var range = $("#Ranges").val(); $.get("Search/Search?section=" + section + "&township=" + township + "&range=" + range, function (response) { $("#cornerDiv").html(response) }); }); }); </script> <h2>Search</h2> <%--The line below is a workaround for a VB / ASPX designer bug--%> <%=""%> <% Using Ajax.BeginForm("Search", New AjaxOptions With {.UpdateTargetId = "searchResults", .LoadingElementId = "loader"})%> Township <%= Html.DropDownList("Townships")%> Range <%= Html.DropDownList("Ranges")%> Section <%= Html.DropDownList("Sections")%> <div id="cornerDiv"> <% Html.RenderPartial("Corners")%> </div> <input type="submit" value="Search" /> <span id="loader">Searching...</span> <% End Using%> <div id="searchResults"></div> </asp:Content>

    Read the article

  • MVC keeping the PartialView in its own context - ignore the main view holding the partial view

    - by Mike
    I'm looking at the partialview components of the MVC Framework. i want my partial view to be handled in its own action and for the rest of the view to handle itself, but i'm getting an exception because the main page is not getting its view fired. Am i going around this the wrong way? My Main View (Jobs/Index.aspx): <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication3.Models.JobViewModel>" %> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% Html.RenderPartial("JobListing", Model.Jobs); %> </asp:Content> The partialview (Jobs/JobListing.ascx): <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<MvcApplication3.Models.Job>>" %> <table> <tr> <td> Job Title </td> <td> Job Location</td> </tr> <% foreach (var job in Model) { %> <tr> <td> <%= job.Title %> </td> <td> <%= job.Location %> </td> </tr> <% } %> <% Html.BeginForm("DoSomeStuff", "Job", null, FormMethod.Post); %> <%= Html.TextBox("SomeInfo") %> <button type="submit" id="submit" /> <% Html.EndForm(); %> The main controller for both the main view (Index) and the partialview (DoSomeStuff()) public class JobController : Controller { public ActionResult Index() { JobProvider provider = new JobProvider(Session); JobViewModel vm = new JobViewModel(); vm.Jobs = provider.GetJobs(); return View(vm); } public PartialViewResult DoSomeStuff() { return PartialView("JobListing"); } } As you can see in the partial view, it has its own form that posts to the Action called DoSomeStuff(). i want this action to handle any data submitted from that form. but when the form is submitted the main action (Index) does not fire and then i get an exception as the Model (.Models.JobViewModel) is not passed to the view that the partialview (JobListings) lives in. basically what im saying is, if i have a myview.aspx with lots of html.RenderPartialView('apartialview') that have forms in them, can i get it so these forms post to their own actions and the main view (with what ever model it inherits) is handled as well. Rather then having all the form submitting code in the main action for the view. am i do this wrong?

    Read the article

  • after return PartialView() Url.Actionlink("Action", "Controller"), the Controller is lost

    - by Johannes
    Well the Question is related to a problem I posted before (http://stackoverflow.com/questions/2403899/asp-net-mvc-partial-view-does-not-call-my-action). In practice I've a partial view which contains a Form, after submitting the Form the Controller returns the Partial View. Well the Problem is if I reload the page which contains the partial view the function <%= Url.Action("ChangePassword", "Account") %> returns "Account/ChangePassword", if I submit the form and the partial is returned by the controller. Using return PartialView() the function <%= Url.Action("ChangePassword", "Account") %> returns only "ChangePassword". Any Idea because? The View looks like: <form action="<%= Url.Action("ChangePassword", "Account") %>" method="post" id="jform"> <div> <fieldset> <legend>Account Information</legend> <p> <label for="currentPassword">Current password:</label> <%= Html.Password("currentPassword") %> <%= Html.ValidationMessage("currentPassword") %> </p> <p> <label for="newPassword">New password:</label> <%= Html.Password("newPassword") %> <%= Html.ValidationMessage("newPassword") %> </p> <p> <label for="confirmPassword">Confirm new password:</label> <%= Html.Password("confirmPassword") %> <%= Html.ValidationMessage("confirmPassword") %> </p> <p> <input type="submit" value="Change Password" /> </p> </fieldset> </div> </form> </div> <script> $(function() { $('#jform').submit(function() { $('#jform').ajaxSubmit({ target: '#FmChangePassword' }); return false; }); }); </script> Part of the Controller: if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword)) { return PartialView(ViewData); }

    Read the article

  • Problems with MVC Ajax.ActionLink and returning a PartialView

    - by mwright
    I'm trying to implement a simple Ajax update using MVC and have run into an issue. My understanding of how to implement Ajax with MVC is to use an Ajax.ActionLink which allows the content to be updated based on user interaction. I have an Ajax.ActionLink that looks like the following: <%= Ajax.ActionLink("Call Ajax", "Ajax", new AjaxOptions{UpdateTargetId = "updateDiv"}) %> If, in the controller, I return a string it works fine. However, when returning a PartialView instead, nothing happens. I can step through and verify that the controller is "returning" the partial view but nothing shows up in what I'm calling the updateDiv. How can I go about determining what the problem is?

    Read the article

  • Passing ViewData to PartialView returned from using Html.Action

    - by RWGodfrey
    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 the returned partial view (MyPartialView) to have access to the ViewData that was set in the base page's controller action but that doesn't appear to be the case. If I insert the partial view by using the following in my base view it works: <% Html.RenderPartial("MyPartialView") %> I don't want to do that though because I want my "MyPartialViewAction" to execute logic to determine WHICH partial view to return.

    Read the article

  • MVC2: Validate PartialView before Form Submit of Page containing Partial View

    - by Pascal
    I am using asp.net mvc2 and having a basic Page that includes a Partial View within a form <% using (Html.BeginForm()) { %> <% Html.RenderAction("partialViewActionName", "Controllername"); %> <input type="submit" value="Weiter" /> <% } %> When I submit the form, the httpPost Action of my Page is called, and AFTER that the httpPost Action of my Partial View is called [HttpPost] public virtual ActionResult PagePostMethod(myModel model) { // here I should know about the validation of my partial View // If partialView.ModelState is valid then // return View("success"); // else return View(model) } [HttpPost] public virtual ActionResult partialViewActionName(myModel model) { ModelState.AddModelError("Error"); return View(model); } But as I am doing the Validation in the httpPost Method of my Partial View (because I want to use my Partial View in several Places) I cant decide if my hole page is valid or not. Has anyone an Idea how I could do this? Isn´t it a common task to have several partial Views in a page but have the information about validation in the page action methods? Thanks very much for your help!!

    Read the article

  • ASP.NET MVC - PartialView not refreshing

    - by Billy Logan
    Hello Everyone, I have a view that uses a javascript callback to reload a partial view. For whatever reason the contents of the partial class do not refresh even though i can step through the entire process and see the page being recalled and populated. Any reason why the page would not display? Code is as follows: <div id="big_image_content"> <% Html.RenderPartial("ZoomImage", Model); %> </div> This link should reload the div above: <a href="javascript:void(0)" onclick="$('#big_image_content').load('/ShopDetai/ZoomImage);" title="<%= shape.Shape %>" alt="<%= shape.Shape %>"> <img src="http://images.rugs-direct.com/<%= shape.Image.ToLower() %>" width="40" alt="<%= shape.Shape %>"> </a> partial view(ZoomImage.ascx) simplified for now, but still doesn't load: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<RugsDirect.Data.ItemDetailsModel>" %> <%= Model.Category.ToLower()%> And finally the controller side of things: public ActionResult ZoomImage() { try { ItemDetailsModel model = GetMainImageContentModel(); return PartialView("ZoomImage", model); } catch (Exception ex) { //send the error email ExceptionPolicy.HandleException(ex, "Exception Policy"); //redirect to the error page return RedirectToAction("ViewError", "Shop"); } } Again, i can step through this entire process and all seems to be working accept for the page not reloading. I can even break on the <%= Model.Category.ToLower()% of the partial view, but it will not be displayed. Thanks in advance, Billy

    Read the article

  • ASP.NET MVC CRUD PartialView Popup Issue

    - by Smiley Face
    I am creating an MVC website which makes use of Partial Views on Popups to handle all my CRUD transactions. Please note that my application can already handle these CRUD operations perfectly (LINQ-To-Entity). However, I have a problem with my popup forms. Below is the code from my _Add.cshtml: @model MyStore.Models.MyModels.ProductsModel @{ Layout = null; } @using (Ajax.BeginForm("_Add", "Products", new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", OnSuccess = "addSuccess" }, new { @id = "addForm" })) { @Html.ValidationSummary(true) <div id="add-message" class="error invisible"></div> <fieldset> <legend>Products</legend> @Html.HiddenFor(m => Model.ProductCode) <div class="editor-label"> @Html.LabelFor(model => model.ProductName) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProductName) @Html.ValidationMessageFor(model => model.ProductName) </div> <div class="editor-label"> @Html.LabelFor(model => model.Price) </div> <div class="editor-field"> @Html.TextBoxFor(model => model.Price) @Html.ValidationMessageFor(model => model.Price) </div> </fieldset> } Below is the code from my Controller: [HttpGet] public ActionResult _Add(string productCode) { ProductsModel model = newProductsModel(); model.ProductCode = ProductCode ; return PartialView(model); } [HttpPost] public JsonResult _Add(ProductsModel model) { if (ModelState.IsValid) { ProductsManager prod = new ProductsManager(); Products pa = new Products(); pa.ProductCode = model.ProductCode; pa.ProductName = model.ProductName; pa.Price = model.Price; prod.AddProduct(pa); return Json(HelperClass.SuccessResponse(pa), JsonRequestBehavior.AllowGet); } else { return Json(HelperClass.ErrorResponse("Please review your form"), JsonRequestBehavior.DenyGet); } } Please note that the _Add.cshtml is a partial view which is being rendered through a Popup.js which I found on the internet. It is rendered through this code: @Html.ActionLink("[Add Product]", "_Add", new { ProductCode = @ViewData["ProductCode"] }, new { @class = "editLink" }) This works okay. I mean it adds product to my database. But my problem is upon clicking the Proceed button, I get this pop-up download dialog from the page: Can somebody please help me with this? I have a hunch it's because of the HttpMethod i'm using (POST, PUT, GET, DELETE) but i'm not really sure which one is right to use or if it really is the problem in the first place. Any help would be greatly appreciated! PS. Sorry for the long post.

    Read the article

  • How do partialviews work in asp.net MVC when passing parameters back?

    - by Rob Ellis
    I have a page with a partialview on it which is a list of items. I have a button on it which shows the next 5 items. This is done via ajax:- using (Ajax.BeginForm("ShowUpdates", new AjaxOptions() { UpdateTargetId = "statusUpdateContainer", InsertionMode = InsertionMode.InsertAfter })) { <input type="submit" class="formbutton" value="Show More" style="width:100%;"/> } My partial view controller: [HttpPost] public ActionResult ShowUpdates(string page, string pagesize) { //get data code hidden here return PartialView("_statusUpdates"); } My question is that I need the 'page' variable to increment each time someone presses the form button which is contained within the partialview. How do I keep track of that variable?

    Read the article

  • Asp.Net WriteSubsitution vs PartialView - the right way

    - by radu-negrila
    Hi, I have a partial view that should not be cached in a output cached MVC view. Usually you write non-cached content by using Response.WriteSubstitution. The problem is that WriteSubstitution takes as a parameter a HttpResponseSubstitutionCallback callback which looks like this: public delegate string HttpResponseSubstitutionCallback(System.Web.HttpContext context) This is where things get complicated since there is no easy/fun way to generate the html on the fly. You have to do a hack like this. So the question is: Is there an easier way to make a partial view not cached ?

    Read the article

  • ASP.NET MVC PartialView generic ModelView

    - by Greg Ogle
    I have an ASP.NET MVC application which I want to dynamically pick the partial view and what data gets passed to it, while maintaining strong types. So, in the main form, I want a class that has a view model that contains a generically typed property which should contain the data for the partial view's view model. public class MainViewModel<T> { public T PartialViewsViewModel { get; set; } } In the User Control, I would like something like: Inherits="System.Web.Mvc.ViewUserControl<MainViewModel<ParticularViewModel>>" %> Though in my parent form, I must put Inherits="System.Web.Mvc.ViewPage<MainViewModel<ParticularViewModel>>" %> for it to work. Is there a way to work around this? The use case is to make the user control pluggable. I understand that I could inherit a base class, but that would put me back to having something like a dictionary instead of a typed view model.

    Read the article

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

    - by Robert Koritnik
    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 avoid returning error partial view. This would look like a success on the client. Having the client parse the result to see whether it's an actual success is prone to errors. Designers may change the partial view output and this alone would break the functionality. So I want to throw an exception, but with the correct error message returned to the ajax client.

    Read the article

  • Is it possible to utilize internal methods on controllers to reduce duplication?

    - by Maslow
    in a partial view I have the following: <%Html.RenderAction(MVC.User.GetComments(Model.UserGroupName)); %> can I render a Controller's PartialViewResult in a View without going through routing so I can pass arguments directly from the model so that the arguments I'm passing to the controller never get sent to the user or seen by the user? Currently the method I'm showing at the top throws an exception because no overload is public. I've got it marked as internal so that a user can not access it, only the rendering engine was my intent.

    Read the article

  • how do you reuse a partial view with 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. should i stick this into my view model as a seperate property "Model.ExerciseDropdown2" for example. is there a better way ?

    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

  • asp.net-mvc return a couple of partial views onclick

    - by niao
    Greetings, I have an asp.net mvc application. When button is clicked (submit button) i would like to results to be displayed inside some div. I know how to do it. I have some action where I return a partial view. But when button is submitted then I get some multiple objects from db and I would like to display them all in div. How can I achieve it?

    Read the article

  • how do you pass in a collection to an MVC 2 partial view?

    - by femi
    hello , how do you pass in a collection to an MVC 2 partial view? I saw an example where they used the syntax; <% Html.RenderPartial("QuestionPartial", question); % this passes in only ONE question object.. what if i want to pass in several questions into the partial view and , say, i want to list them out...how would i pass in SEVERAL questions? thanks

    Read the article

  • Is there an event that raises after a View/PartialView executes in ASP.NET MVC 2 RC2?

    - by sabanito
    I have the following problem: We have an ASP.NET MVC 2 RC 2 application that programmatically impersonates an AD Account that the user specifies at logon. This account is used to access the DB. At first we had the impersonating code in the begin_request and we were undoing the impersonation at the end_request, but when we tried to use IIS 7.5 in integrated mode, we learned that it's not possible to impersonate in the Global.asax so we tried different things. We have succesfully moved our code from the BeginRequest to the ActionExecuting event and the EndRequest to the ResultExecuted, and now, about 80% of our code works. We've just discovered that since we're passing the Entity Framework objects as models for our views, there's this remaining 20% that won't work because some Navigation Properties are not loaded when the view begins it's execution, so we're getting connection exceptions from Sql Server. Is there any event or method that executes AFTER the view, so we can undo the impersonation in it? We thought ResultExecuted will do just that, but it doesn't. We've been told that passing the plain Entities into the view as models is not a good idea, but we have A LOT of views that may have this problem and there's not automated way to know it. If some of you could explain why it's not a good idea, maybe we can convince the team to fix it!

    Read the article

  • How to Generate Embeddable Widgets, and Return PartialView, JS & CSS as JSONP?

    - by DaveDev
    I found this question which is a great starting point towards creating embedded widgets that enable showing dynamic content on remote sites (i.e. a different domain). One problem I'm having is with the following code: public ActionResult SomeAction() { return new JsonpResult { Data = new { Widget = "some partial html for the widget" } }; } It says Widget = "some partial html for the widget" but this doesn't really mean anything to me. I assume that Widget would contain the HTML representing what the user wants to see on the screen, but How do I get the contents of my Partial View into Widget? Can anyone point me in the right direction? Thanks..

    Read the article

  • Returning a JSON view in combination with a boolean

    - by Rody van Sambeek
    What i would like to accomplish is that a partiel view contains a form. This form is posted using JQuery $.post. After a successfull post javascript picks up the result and uses JQuery's html() method to fill a container with the result. However now I don't want to return the Partial View, but a JSON object containing that partial view and some other object (Success - bool in this case). I tried it with the following code: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, Item item) { if (ModelState.IsValid) { try { // ... return Json(new { Success = true, PartialView = PartialView("Edit", item) }); } catch(Exception ex) { // ... } } return Json(new { Success = false, PartialView = PartialView("Edit", item) }); } However I don't get the HTML in this JSON object and can't use html() to show the result. I tried using this method to render the partial as Html and send that. However this fails on the RenderControl(tw) method with a: The method or operation is not implemented.

    Read the article

  • Overloading Controller Actions

    - by DaveDev
    Hi Guys I was a bit surprised a few minutes ago when I tried to overload an Action in one of my Controllers I had public ActionResult Get() { return PartialView(/*return all things*/); } I added public ActionResult Get(int id) { return PartialView(/*return 1 thing*/); } .... and all of a sudden neither were working I fixed the issue by making 'id' nullable and getting rid of the other two methods public ActionResult Get(int? id) { if (id.HasValue) return PartialView(/*return 1 thing*/); else return PartialView(/*return everything*/); } and it worked, but my code just got a little bit ugly! Any comments or suggestions? Do I have to live with this blemish on my Controllers? Thanks Dave

    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

1 2 3 4 5  | Next Page >