razor

How to distribute razor views to another application in .NET Core

本秂侑毒 提交于 2019-12-24 10:13:45
问题 I have created web application - Asp.Net MVC in .NET Core . This application contains some Razor Views but I would like to share these views to another application like for example with DLL or like middleware. Here is some information about example with distribution Controllers but around Views nothing special - https://docs.microsoft.com/en-us/aspnet/core/mvc/advanced/app-parts I've tried add Controller like this: var assembly = typeof(Project.HomeController).GetTypeInfo().Assembly; services

.NET MVC Razor - Scoped Styles

元气小坏坏 提交于 2019-12-24 10:11:57
问题 Currently I'm trying to use a partial view inside one of my views which uses a different css style sheet. However, the styles from the main view are being carried over because of the way styles are rendered in Razor: @Styles.Render("~/Content/css") simply applies to everything, and I can't seem to find any documentation on scoped css in Razor. Doing the below code does not work - I believe because Razor handles Styles.Render by simply placing in the head. <div> <style scoped> @Styles.Render("

ASP.Net MVC3 Parent Child Model Binding

僤鯓⒐⒋嵵緔 提交于 2019-12-24 09:56:12
问题 I have a partial template that uses a User object as a model. The user has a collection of Accounts. On this partial template I have a loop as follows. The _Account partial template is bound to the Account class @foreach (var item in Model.Accounts) { <tr> <td colspan="6"> <div> @Html.Partial("_Account", item) </div> </td> </tr> } In my controller method I initially tried [AcceptVerbs(HttpVerbs.Post)] public ActionResult UserDetails(User user, string actionType) But the User.Accounts

Is it any value of adding one script file to BundleCollection?

荒凉一梦 提交于 2019-12-24 09:37:54
问题 I am designing a very big application now and i want to make good infrastructure for the future. In Razor (MVC) there is an option to include javascript files in a view by using the function @Scripts.Render("~/Scripts/myscript.js") by specify a specific file or bundle item from BundleCollection which defined in BundleConfig.cs. I am wondering, is there any added value to define a bundle item in the Scripts.Render function of only single file instead of specify the script file itself? one of

Razor “The type or namespace name 'x' could not be found” Error. Compile Only

孤人 提交于 2019-12-24 09:28:30
问题 I have run into an issue with my razor templates. In the the template I am using it has two using references at the top of the file. @using Framework; @using Bundler; Both of these reference internal namespaces in my project that are both included as refs in the project that is compiling the template. However the bundler reference fails with the classic. Unable to compile template. The type or namespace name 'Bundler' could not be found (are you missing a using directive or an assembly

Rendering a partial view with jquery

允我心安 提交于 2019-12-24 09:28:08
问题 The problem; I have a view with two partial views one view to handle client side msgs and a gridview. the gridview is a form and can delete update items. When deleting or updating error/success msgs are generated in tempdata however only the grid partialview is being rendered from the actionresult functions. I need a way to simply render the messages partial view without posting anything or redirecting it to the controller since the data already exists in tempData. View: <div id="page

MVC BeginCollectionItem

别等时光非礼了梦想. 提交于 2019-12-24 09:28:05
问题 I'm having some issue getting my partial view BeginCollectionItem to save to the database. I have a form which has a dynamic number of "sections" that can be added to the page, and within each of these fields there is a text box where the user can enter the section name. As far as I can tell the BeginCollectionItem within the partial view is working properly, however I cannot post the info to the database. In my other forms I have used a [bind()] to send the data to the database, is it

DisplayFor is not keeping data in ViewModel on PostBack

两盒软妹~` 提交于 2019-12-24 09:21:47
问题 This question has been asked before by other, but still don't get it. I am using MVC3 Razor and I have screen for entering trouble tickets. Once data (a textarea note) is entered, the controller redirects back to the same screen. Most of the data is for display only. If I use DisplayFor or DisplayTextFor, the data is not being posted back. I have used HiddenFor. That works. However, I keep hearing from others that HiddenFor is not ideal. I don't want to editorfor because, I want to easily

ASP.Net MVC 3 client side validation with a 3 tabs form

故事扮演 提交于 2019-12-24 08:48:35
问题 I have to build a registration form using asp.net mvc 3 jquery validate. That form is composed of approx 20 fields splitted in 3 JS tabs due to UI and navigation style. I wrote all my validation on the serverside through annotations in the profile model: namespace Web.Models { public class ProfileModel { //companyName [Required(ErrorMessageResourceType = typeof(Core.Resources.Resources), ErrorMessageResourceName = "CompanyNameRequired")] [StringLength(50, ErrorMessageResourceType = typeof

Rendering a sublist of a list in .net MVC

只愿长相守 提交于 2019-12-24 08:46:22
问题 I'm still learning .net MVC, and perhaps am not searching correctly for what I need to find a solution to. In short, I have a table in the database that is structured as: ID Category Subcategory FK So each category may appear multiple times, as well as each subcategory, which is unique to the category. I want to render a menu in the view that looks like: Category 1 Subcategory 1a Subcategory 1b Subcategory 1c Category 2 Subcategory 2a Subcategory 2b And so on. Right now in the controller I