partial-views

ASP.NET MVC3 ajax partial view refresh

微笑、不失礼 提交于 2019-12-06 10:52:34
I am facing a problem with ajax updating of div in asp.net mvc3. I have a View with content <div id="post_comments"> @{Html.RenderPartial("_RefreshComments", Model);} </div> <div id="commentForm"> @using (Ajax.BeginForm("Details", new { id = Model.Post.PostId }, new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.InsertAfter, UpdateTargetId = "post_comments" } )) { // form content goes here <p id="buttons"> <input type="submit" value="@Strings.Save" /> </p> } This is my partial view @model Project.Models.Posts.PostDetailsViewModel @{ foreach (var c in Model.ApprovedComments) {

Best way to support multiple forms in mvc3 with validation annotiation

主宰稳场 提交于 2019-12-06 09:41:15
In an mvc3 project I want to have 2 forms on one page. One form is to register a user and the other one is to logon. There are two submit buttons. One to register, one to logon. In the model there are validation annotiation e.g. username is required, passwords must match and so on. The problem is, that the validation annotiation affect each other. So that when the register button is pressed, the validation for the logon username is invalid. I have tried to write partial views, or to do everything in one view an write some custom annotiations, respecting the pressed button. But that all seems

Is it possible to pass a partial view a different model than the model used by the view it is in?

做~自己de王妃 提交于 2019-12-06 09:22:07
I tried to do it but I get an error saying that model x was expected but y was passed in. Yes. In fact you can use any class, but it has to match the @model declaration of your partial view. Partial View: @model partialViewModel <h2>@Model.partialViewModelProperty</h2> Main View: @model mainViewModel <h1>Model.mainViewModelProperty</h1> @Html.Partial("_PartialView", new partialViewModel() { partialViewModelProperty = "A title" }) No, that is the point of a strongly-typed View. It requires a certain type. A partial view would handle this the same as any other view. 来源: https://stackoverflow.com

ASP.NET call a controller method from the master page?

谁说我不能喝 提交于 2019-12-06 08:05:59
In ASP.NET MVC2 how do you call a controller method from the master page? Say for example I wanted to include some overview data in the master: +--------------------------------------+ | Logo Welcome xyz| +--------------------------------------+ | total sales this month $999 | +--------------------------------------+ | Home | Sales | Import | Export (menu)| +--------------------------------------+ And I have inside the Sales controller this method: public ActionResult TotalSalesThisMonth() { var totalSalesModel = SalesService.GetTotalSalesThisMonth() return View(totalSalesModel); } How can I

Reloading Partial View with JQuery

谁都会走 提交于 2019-12-06 07:20:10
I have a page with a video at the top and a list of videos you can choose from. Currently, clicking a link in the video list will reload the entire page. I need it to only refresh the partial view I have containing the video at the top of the page. I saw several posts here on SO showing how to reload partial views with JQuery, but couldn't get it to work correctly in my situation. I'm unsure how to pass the correct id of the video along. Controller: public ActionResult Videos(int topVideo = 0) { VideosModel model = new VideosModel(); model.Videos = StatsVideoService.GetEntityList(new Lookup

Jquery Modal Dialog displaying MVC3 partial view - works first click only

天大地大妈咪最大 提交于 2019-12-06 05:27:17
问题 public ActionResult MeanQ(int id) { Access access= db.Access.Find(id); return PartialView("_MeanQPartial", access); } The partial view thats being rendered in the above code is displayed in a Dialog Modal (Jquery)...The link(onclick) that displays the partial view in a Jquery Modal Dialog works well for the first click. Once I close that dialog and click on the link again, the Partial View does not open as expected in a pop up form. It opens as a new page in the browser. How can I make the

Laravel multiple nested views

扶醉桌前 提交于 2019-12-06 04:47:22
问题 I'm using laravel layouts and I have a setup like this; //Controller public function action_index() { $this->layout->nest('submodule', 'partials.stuff'); $this->layout->nest('content', 'home.index'); } // layout <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> @yield('content'); </body> </html> // this is the content template @section('content') <div> @yield('submodule') </div> @endsection My question is how can I insert a partial template

ASP.NET MVC3 Upload a file from a Partial view (and fill the corresponding field in the Model)

僤鯓⒐⒋嵵緔 提交于 2019-12-06 03:19:21
I know the subject has already been discussed on SO and elsewhere, but I can't find any answer to my question. I'm working on an ASP.NET MVC3 project, and I'd like to create a Partial view containing a FileUpload . This partial view is called on a basic Create page, and I'd like the file to upload belongs to the model to create. It is only when the user will submit the form the selected file will be uploaded. Here is an explanation by the code : Model ModelToCreate public class ModelToCreate { //Some properties public FileUploadModel Files { get; set; } } Model FileUploadModel public class

Javascript and MVC4 partial views loaded with AJAX

不问归期 提交于 2019-12-06 02:17:20
问题 I have an ASP.NET MVC 4 view that dynamically loads two nested partials into <div> elements via JQuery AJAX calls. Each of the partials has a pretty big pile of Javascript of its own. To get it all working, I currently have all of the Javascript in the success of each AJAX call: function LoadPartial(someImportantId) { $.ajax({ url: '@Url.Action("LoadThePartial")' + '?id=' + someImportantId, type: 'POST', async: false, success: function (result) { $("#partialContainerDiv").html(result); //here

Difference between MVC 3 Partial Page (Razor) and MVC 3 View Page with Layout (Razor)?

微笑、不失礼 提交于 2019-12-05 21:30:50
问题 In MVC 3 Beta, is there a difference between the templates MVC 3 Partial Page (Razor) and MVC 3 View Page with Layout (Razor) ? I added a partial page (_partialList) to my application. Now when I return only the partial view, it applies the Layout present in _ViewStart.cshtml - acting very much like a stardard view page with layout. if (Request.IsAjaxRequest()) return View("_partialList", someModelData); How does a "partial" page distinguish itself from a standard view page with layout ? Will