razor

How to use CheckBoxList and DropdownList in MVC4 Razor

不羁岁月 提交于 2019-12-19 11:56:15
问题 I have to use @Html.CheckBoxListFor<> or @Html.DropdownListFor<>.I am confused about how to use these helper class in View whild I am using List for Model Binding. What is the Right and Easiest way to Bind List into CheckBoxList and DropdownList. In Model: public class SampleViewModel { public IEnumerable<Responsible> AvailableResponsibles { get; set; } public IEnumerable<Responsible> SelectedResponsibles { get; set; } public PostedResponsibles PostedResponsibles { get; set; } Responsible

Using ASP.NET Server Controls in MVC?

£可爱£侵袭症+ 提交于 2019-12-19 11:45:32
问题 On my current project I need to add a functionality that allows the user to view a thumbnail of their uploaded PDF. I've found a handy component that achieves this (the basic version is free, but it's enough for my current needs). Anyways, the control is pretty outdated (2010), therefore there doesn't seem to be MVC support. On the demos they depict usage of the control as such: The View's Markup: <form method="post" runat="server" enctype="multipart/form-data"> <asp:Panel ID="thumbnailsPanel

Asp.net MVC Razor how to show grouped radio buttons for two model fields

你离开我真会死。 提交于 2019-12-19 10:33:27
问题 I have a simple quiz model, and I am trying to let the user select Correct Answer/Alternative answer from two radio buttons, grouped , in a strongly typed view. But the lambda expressions I use aren't working. I get two blank radio buttons. I have looked at several questions here, and online but my model is an IList<>, and I can't find a suitable example. All examples I found work with a non-IList<>. This is my Model Model: public partial class Question { public int QuestionID { get; set; }

ASP.NET core 2 act as reverse proxy usering rewrite middleware

一世执手 提交于 2019-12-19 10:31:35
问题 I'm struggling to make my asp.net core 2 app act like a reverse proxy using URL Rewrite rules. I have the following in my startup.cs: var rewriteRules = new RewriteOptions() .AddRedirectToHttps(); .AddRewrite(@"^POC/(.*)", "http://192.168.7.73:3001/$1", true); app.UseRewriter(rewriteRules); The rewrite rule is exactly as it is in my IIS settings (which I'm trying to replace with this method) which works fine. I'm assuming it has something to do with forwarding the headers maybe? Or maybe I

How to populate a textbox based on dropdown selection in MVC..?

送分小仙女□ 提交于 2019-12-19 10:24:49
问题 Hi I have created a table and connected it to MVC project through ADO.NET entity. After connecting I added the controller for the entity and it creates a set of cshtml files in VIEW folder in MVC project. But now What I need is to create a dropdownlist and textbox. I created the dropdownlist in a cshtml file and also wriiten the logic for it in the CONTROLLER. I can also create TEXTBOXES,but i'm facing the problem of poulating TEXTBOX based on the dropdownlist selection. My Model auto

how to create a view with multiple models mvc 4?

落花浮王杯 提交于 2019-12-19 10:14:03
问题 so i works in asp.net mvc 4 project and i have a problem in my view, what i want is create a view with 2 differnt type of model,first view (Index) take IEnumerable (Models.myModel) the second (subscriber Details) take Models.myModel, this is my Model code : public class SubscribersModel { [Required] [DataType(DataType.Text)] public string name { get; set; } [Required] [DataType(DataType.Text)] [StringLength(maximumLength: 10, MinimumLength = 7)] public string cin { get; set; } [Required]

How to Add new Row Dynamically in ASP.Net MVC 5

妖精的绣舞 提交于 2019-12-19 10:09:12
问题 I am looking for help on how to add a new row of LineItems to an Invoice in a create Razor view of an ASP.Net MVC 5 application. I have read almost all similar questions but none have addressed what I thought was a simple use case. Here is my Invoice model class public class Invoice { public int Id { get; set; } public int InvoiceNumber { get; set; } public List<LineItem> LineItems { get; set; } public Client Customer { get; set; } public DateTime DateCreated { get; set; } public decimal

Razor proxy type error. System.Data.Entity.DynamicProxies

眉间皱痕 提交于 2019-12-19 10:04:44
问题 I have a class User and then another Type UserSpecial with some special user properties. I pass it in razor to the partial method class to create the UserSpecial form which expects an object of type User Special but i get an error. @model User @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> @Html.Partial("../UserSpecial/_CreateOrEdit", Model.UserSpecial) <p class="submit clear"> <input type="submit" value="Register" /> </p> </fieldset> } </div> Error i get - The model

Is there an example on using Razor to generate a static HTML page?

喜夏-厌秋 提交于 2019-12-19 10:03:49
问题 I want to generate a static HTML page by RAZOR, basically by using includes of partial sub pages. I have tried T4 as well and do look for an alternative: see here and here This answer says it is possible - but no concrete example I have installed Razor generator because I thought this is the way to go, but I do not get how to generate static HTML with this. Best would be a complete extension which behaves like the T4 concept, but allows me to use the RAZOR syntax and HTML formatting (the

Extension Method and Razor Page

喜你入骨 提交于 2019-12-19 09:00:10
问题 I have defined an extension method in app_code like below. public static class Extensions { public static string Hi(this object obj) { return "hi"; } } In the razor page, anything can say Hi :) @Html.Hi(); @Request.Hi(); @this.Hi(); But @Hi() doesn't work. Is there a way to make @Hi() work? 回答1: C# only allows you to call extension methods qualified by an object instance. If you have an extension method that extends your type, you can't call it "directly"; you need to write this