partial-views

asp.net MVC3 partial view result not updating EditorFor value

冷暖自知 提交于 2019-12-09 23:05:57
问题 I have a simple email capture form as part of my home page, however when I return the partial view the model value for the Editor for form is not getting updated: The Model public class Contact { [Key] public int Id { get; set; } [Required] public string Email { get; set; } [NotMapped] public string Message { get; set; } } The Views @model TestApp.Models.Contact @{ ViewBag.Title = "Home Page"; } <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>

Razor @helper in App_Code cannot be accessed

℡╲_俬逩灬. 提交于 2019-12-09 16:51:29
问题 In my App_code , I have a helper function called FormatTelephone(string number) in Formatter.cshtml . I tried to access it in a partial view by @Formatter.FormatTelephone(number) . When I test it, it says Compiler Error Message: CS0103: The name 'Formatter' does not exist in the current context What is the likely cause of it? Thanks! 回答1: I ran into this exact problem when deploying the site onto another server. Make sure the App_Code/Formatter.cshtml file is actually copied to the server! My

Why do I need an underscore for partial views in asp.net mvc

强颜欢笑 提交于 2019-12-09 07:53:35
问题 Just to distinguish between a view used inside a dialog or used in a foreach loop (customer details) ? 回答1: You don't need an underscore. It's just a convention, and MVC is very keen on using conventions. 回答2: Mike Brind has put this nicely in the question Why does Razor _layout.cshtml have a leading underscore in file name?: Since layout pages in Web Pages are not intended to be served directly, they are prefixed with the underscore. And the Web Pages framework has been configured not to

AJAX to update micropost vote up/down partial only refreshes the most recent post

萝らか妹 提交于 2019-12-09 07:33:26
Using Rails 3, JRuby. I wanted to incorporate a "vote up" and "vote down" rating for my Rails social application, that allows users to essentially like and dislike posts. This worked great, however refreshed the whole page whenever a post was voted on. To solve this, I wanted to implement a partial refresh that would only update that particular post score, within the post feed. I followed my usual pattern to implementing AJAX partial refreshing, however, the outcome isn't quite what I had in mind. Instead of refreshing the post I like/dislike, it refreshes the most recent post with the new

MVC System.Web.HttpCompileException on Html.RenderPartial

ⅰ亾dé卋堺 提交于 2019-12-08 18:38:02
问题 I'm getting an System.Web.HttpCompileException when the my view calls Html.RederPartial . The exception message is: Additional information: External component has thrown an exception. I've checked that the: Controller doesn't throw an exception Partial view does exist The Model passed by controller and received by the view is the same. The InnerException is null The exception sounds like it should be that the html or razor is malformed or incorrect, but the solution builds fine. It was also

How to execute JavaScript function on PartialView load in MVC 3

本秂侑毒 提交于 2019-12-08 16:22:10
问题 \\code public ActionResult mapPartial(DataTable dt) { string strEvents = "["; foreach (DataRow row in dt.Rows) { strEvents += "[" + row["Lat"].ToString() + ", " + row["Long"].ToString() + ", " + "\"" + row["LastName"].ToString() + row["DateOfBirth"].ToString() + "\"" + "],"; } strEvents = strEvents.Remove(strEvents.LastIndexOf(",")); strEvents += "]"; ViewBag.locpoints = strEvents; return PartialView(dt); } //in the partial view page <script type="text/javascript"> function mapInit(Viewbag

Populate single dropdown from two tables

。_饼干妹妹 提交于 2019-12-08 15:07:13
问题 The scenario is: Data is stored in database in project and neighbourhood tables both. Now, i want to populate dropdown with project id and project name and neighbourhoodId and neighbourhood name. i am right now sending through viewBag like this: ViewBag.NeighbourhoodId = new SelectList(allNeighbourhood(), "Id", "NeighbourhoodName"); on view page, getting dropdown populated like this: @Html.DropDownList("Locations", ViewBag.NeighbourhoodId as SelectList, "Select a location") Now,how to send

How to redirect full page rather then only partial view changing?

。_饼干妹妹 提交于 2019-12-08 14:21:38
问题 I have a situation where I am on a controller called customer, and I have an account method which I called using a customer number as the identifier. I then have an ActionLink that takes me to Arrears task with the task form in a partial view of arrears index. on loading this I store the Request.ServerVariables["http_referer"] so I can use that to return. When I then use Return Redirect() with the referrer it does the redirect but loads in the partial section like it was loading in an iframe

Rendering view in ASP.Net MVC

旧街凉风 提交于 2019-12-08 13:38:28
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 calling the same partial 'PV1', hence it is doing this too ... but when rendering the view it don't print

Rails partial iframe missing assets

风流意气都作罢 提交于 2019-12-08 09:48:18
问题 I'm trying to create an iframe that's placed on an other website (not mine) and renders one partial of my site. Everything works well but the content of the iframe (my site) doesn't seem to have any assets included. I'm using Rails 4.0.4. I think it happens because the application.html.erb isn't loaded because I'm just rendering a partial. Here is the iframe code: <iframe src="<%= url_for controller: 'welcome', action: 'iframe' %>" scrollbars="auto" height="480" width="320" name="RiverOfNews"