partial-views

Razor @helper in App_Code cannot be accessed

孤街醉人 提交于 2019-12-04 04:23:37
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! 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 mistake was the file has a build action that was set to ' None '. Right click on the file and select

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

微笑、不失礼 提交于 2019-12-04 03:50:23
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 the two behave differently in any particular scenario? marcind Darin's response solves your practical

RenderSection not working inside Partial View in ASP.NET MVC3

大憨熊 提交于 2019-12-04 02:12:41
In my ASP.NET MVC3 project I have a standard _Layout.cshtml generated by Visual Studio 2010 and after closing my <body> tag, I place a RenderSection : _Layout.cshtml: </body> <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> @RenderSection("ScriptContent", required: false) </html> Then in my Index.cshtml View I have: @model MyApp.ViewModels.MyViewModel @{ Html.RenderPartial("MyPartial", Model); } If I place the @section ScriptContent in the Index.cshtml it displays correctly. If I place it in my Partial View MyPartial.cshtml : @model MyApp.ViewModels

rails access view name inside partial

久未见 提交于 2019-12-04 00:41:47
I have a partial that I am using in different pages. I want to conditionally hide a certain div inside the partial based on the view that is rendering it. I was thinking about creating a page specific javascript file that would look up the div and and hide it. But, if there was a way to retrieve the view name / page name inside the partial it would be central to the partial and would not necessitate loading the same javascript file in multiple pages. Does anybody know a way to do this inside a partial jhdavids8 While @wahaj's answer would work, if you want to do what you need in a central

Render partial form in jQuery dialog

若如初见. 提交于 2019-12-03 21:50:50
Most of you probaly know Nerddinner.com, and my page is much like that, so let's imagine doing this to Nerddinner. When editing a dinner, you'll be redirected to Dinners/Edit.aspx, and presented of the partial view DinnerForm.ascx of type DinnerFormViewModel. What if you wan't this DinnerForm presented in a jQuery UI Dialog? I'm thinking: On the page where you choose to edit the dinner, you'll have a div containing the partial view DinnerForm: <div id="editDinnerForm"> <% Html.RenderPartial("DinnerForm", chosenDinnerToEdit); %> </div> So when you select a dinner to edit, that div is presented

ASP.NET MVC 3 Partial View dynamically rendered and linked from dynamic list in view

耗尽温柔 提交于 2019-12-03 21:26:29
In my MVC 3 application, I will have a view that will contain a partial view. The view itself will have a list of dynamically generated links. The link has to cause the partial view to render detailed information for that linked item. Would I use Ajax for this? If so, since I haven't worked with Ajax before, is there any documentation for using it in a MVC 3 app? Also when the view is first loaded, the partial view will either not be loaded or ideally show another separate partial view. Any thoughts on a good way of doing this? Thanks for the help. Create an action method which returns a

ASP.Net MVC partial views keeping their model state?

时光怂恿深爱的人放手 提交于 2019-12-03 17:37:13
问题 This is probably again a newbie question. When I create an ASP.NET MVC2 application, an Account Controller with an Action LogIn is created like this: [HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { FormsService.SignIn(model.UserName, model.RememberMe); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); }

Rails 3: How do I call a javascript function from a js.erb file

 ̄綄美尐妖づ 提交于 2019-12-03 16:22:02
Now that I've upgraded to Rails 3, I'm trying to figure out the proper way to separate and reuse pieces of javascript. Here's the scenario I'm dealing with: I have a page with two areas: one with elements that should be draggable, the other with droppables. When the page loads I use jQuery to setup the draggables and droppables. Currently I have the script in the head portion of application.html.erb, which I'm sure is not the right solution but at least works. When I press a button on the page, an ajax call is made to my controller that replaces the draggables with a new set of elements that

Display mvc partial view with errors on parent page

不问归期 提交于 2019-12-03 15:37:55
I have a page with multiple forms, each as a partial. I want to post each partial on submit. If there are errors, I want the validation errors to show in the partial as part of the main page i.e. I don't want to just see the partial on it's own page if there are errors. Am I correct in saying this behavior is only possible with an ajax post? How would I return the model state errors WITHOUT an ajax post, just a normal form post? Edit: Still seeing the partial on it's own page Partial - @using (Html.BeginForm("Login", "Account", FormMethod.Post, new { id = "LoginForm" })) { @Html

Update A Partial View From Another Partial View - ASP.NET MVC2

拈花ヽ惹草 提交于 2019-12-03 14:28:29
I want to have two partial views , one for SEARCH and one for SEARCHRESULTS . I want to update SEARCHRESULTS when the "Search" Button is clicked on the SEARCH partial view form. SEARCHRESULTS needs to have the form data fed to it from the SEARCH partial view. I'm not totally sure how to go about this. Can I update the SEARCHRESULTS partial view from my SEARCH partial view's Controller action? General Discussion In the MVC design pattern views are unaware of each other. They may be bound together by the concept of a view assembling multiple partial views but even then the partials are ignorant