razor

ASP.NET Actionlink with glyphicon and text with different font

早过忘川 提交于 2020-01-09 06:05:10
问题 I want to present a button with @Html.ActionLink but i need to have my application font in the text. With this code: <span> @Html.ActionLink(" Create New", "Create", null, new { @class = "btn btn-warning glyphicon glyphicon-plus-sign" }) </span> I get my button but the Create New text appears with the glyphicon font-family. Putting the glyphicon classes in the span doesn't change anything 回答1: You should not add the glyphicon class to the a-tag. From the Bootstrap website: Don't mix with

Razor reseverd words

荒凉一梦 提交于 2020-01-09 05:22:14
问题 That the razor syntax is neat, there's little arguing about. But i can't seem to find it anywhere... What are the razor reserved words? @using @inherits @functions @section Do you know any other? 回答1: Here's a list of Razor reserved keywords ( Note : This applies to cshtml, vbhtml follows VB's rules): Razor-specific keywords inherits functions section helper model (only in MVC projects) You can escape these using @(inherits) Language-specific Razor keywords These are C# keywords that are

Razor reseverd words

不打扰是莪最后的温柔 提交于 2020-01-09 05:22:06
问题 That the razor syntax is neat, there's little arguing about. But i can't seem to find it anywhere... What are the razor reserved words? @using @inherits @functions @section Do you know any other? 回答1: Here's a list of Razor reserved keywords ( Note : This applies to cshtml, vbhtml follows VB's rules): Razor-specific keywords inherits functions section helper model (only in MVC projects) You can escape these using @(inherits) Language-specific Razor keywords These are C# keywords that are

razor view with anonymous type model class. It is possible?

半城伤御伤魂 提交于 2020-01-09 04:59:04
问题 I want to create a view using razor template, but I do not want to write a class for model, because in many views i will have many queries which will be returning diferent models. For example I have a linq query: from p in db.Articles.Where(p => p.user_id == 2) select new { p.article_id, p.title, p.date, p.category, /* Additional parameters which arent in Article model */ }; I need to write a View for this query. This query returns a Articles. Now I dont know how should looks like a model

DataAnnotations validation (Regular Expression) in asp.net mvc 4 - razor view

泪湿孤枕 提交于 2020-01-08 17:34:40
问题 The DataAnnotations validator not working in asp.net mvc 4 razor view, when using the special characters in the regular expression. Model: [StringLength(100)] [Display(Description = "First Name")] [RegularExpression("^([a-zA-Z0-9 .&'-]+)$", ErrorMessage = "Invalid First Name")] public string FirstName { get; set; } Razor View: @Html.TextBoxFor(model => Model.FirstName, new { }) @Html.ValidationMessageFor(model => Model.FirstName) The unobtrusive validation is rendered in view as: <input type=

Html.DropDownList selected value does not work when i specify the name

二次信任 提交于 2020-01-07 05:59:18
问题 I am trying to select a specific option from a dropdown list when the page is rendered. On my Controller I have this code: ViewBag.PropertyId = new SelectList(db.Properties, "PropertyId", "PropertyName", id.ToString()); On my view, This does not work. The selected option is the first option always. @Html.DropDownList("PropertyId", (SelectList)ViewBag.PropertyId) This does work on my view, the correct option is selected. However, I can not save this because I need the name of the select list

Objects in ICollection not passed with model to view

空扰寡人 提交于 2020-01-07 05:52:10
问题 I'm trying to create a site with news that can have comments. I've been following guides from pluralsight.com and I've followed what is done in the guide to the letter but when i debug and look at what's inside the model at runtime the comments aren't included. My DB class: public class ProjectDB { public DbSet<ContentNode> ContentNodes{ get; set; } public DbSet<Comment> Comments { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating

Entity Framework, relation between two tables

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-07 05:35:09
问题 My model classes are: public class User { public User() { Polls = new List<Poll>(); } public int Id { get; set; } public String FirstName { get; set; } public String LastName { get; set; } ICollection<Poll> Polls { get; set; } } public class Poll { public int Id { get; set; } public int PositiveCount { get; set; } public int NegativeCount { get; set; } public String Description { get; set; } public User User { get; set; } } public class PollsContext : DbContext { public DbSet<User> Users {

Using a simple vue.js/webpack setup, how does one configure the dev server to proxy everything EXCEPT a few .js and .vue files?

给你一囗甜甜゛ 提交于 2020-01-07 03:37:10
问题 So some quick background on the site's current setup: My company's site currently runs off of a CMS. All pages are generated and routed via the CMS, so there are no .html files anywhere. It's all generated via razor (.cshtml), the CMS as a backend/data-store, and routing is handled through the CMS. If it were up to me I'd rewrite the entire thing, but I don't have that luxury. I'm doing my best to rewrite the site with a Vue.js + webpack front-end wherever possible and slowly rebuild this

ASP.NET MVC how to populate a collection to a 4 column table?

末鹿安然 提交于 2020-01-07 03:03:55
问题 I have a collection which I passed from my MVC controller to my view. In my view, I want to list the image and its description in a 4 column table. I did not use a grid. So, If I get collection of 8, I will get a gallery list of 4 items in 2 rows of the table. If I get 16, I will get 4 columns in 4 rows of the table. In my code, I started off with add all the product items in one row. I need to add a new row after each set of 4 items. How can I do that? Is there a better control to use?