html-helper

How to determine if a PropertyType is foreign key

蓝咒 提交于 2019-12-01 17:41:18
问题 I have the following class 'schakeling', generated with EF, representing a database table 'schakeling'. In the database 'id' is the primary key and 'plc_id' is a foreign key. public partial class schakeling { public schakeling() { this.verbruik = new HashSet<verbruik>(); } public int id { get; set; } public int plc_id { get; set; } public string var_output { get; set; } public string omschrijving { get; set; } public int vermogen { get; set; } public Nullable<bool> status { get; set; } public

MVC View: Type arguments Html helper DisplayFor cannot be inferred from the usage

旧巷老猫 提交于 2019-12-01 16:28:15
问题 I'm trying to make use of the extended HTML Helper DisplayFor in this View: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcCms.Web.ViewModels.SubscriptionsViewModel>" %> <% using (Html.BeginForm("TrainingSubscription", "Account", FormMethod.Post)) { %> <%: Html.DisplayFor(m => m.Subscriptions) %> <input type="submit" value="Save" /> <% } %> with the following ViewModel namespace MvcCms.Web.ViewModels { public class

CakePHP: image inside link, want to make link point to image location

放肆的年华 提交于 2019-12-01 12:35:23
I have some images inside links that I want to essentially look like this: <a href="/path/to/img.png"><img src="/path/to/img.png" /></a> Clicking on the link should load the image it contains. I'm trying to use CakePHP's HTML helper to do this, as follows: <?php echo $html->link( $html->image('img.png'), 'img.png', array('escape' => false) ); ?> When I do this, however, I get the following code: <a href="/pages/img.png"><img src="/path/to/img.png" /></a> Without using absolute URLs , can I make the link's href attribute point to the image's correct location? Thanks! This should do the trick:

Can't create HtmlHelper methods in VB MVC app

若如初见. 提交于 2019-12-01 12:00:56
I can't figure out what I'm missing in the following code. I've got a method that should add a (dummy) helper extension: Imports System.Runtime.CompilerServices Namespace HtmlHelpers Public Module HelpExtensions <Extension()> _ Public Function HelpMe(ByVal HtmlHelper As HtmlHelper) As String Return "<a>HELP</a>" End Function End Module End Namespace My view looks like this: <%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <%@ Import Namespace="HtmlHelpers" %> <asp:Content ID="indexContent" ContentPlaceHolderID="body" runat="server"> <%

What HTML helper do I use to create a simple dropdownlist that doesn't take in any variables?

大憨熊 提交于 2019-12-01 11:52:15
问题 I want to have a simple select->option dropdown list that I am not passing any (SelectItem collection) values to. I already know the values so I don't need to do all that (they are static). Need to do something like so: <select id="day" name="day"> <option value="1">Sunday</option> <option value="2">Monday</option> </select> <select id="hour" name="hour"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> All examples

What HTML helper do I use to create a simple dropdownlist that doesn't take in any variables?

China☆狼群 提交于 2019-12-01 11:49:10
I want to have a simple select->option dropdown list that I am not passing any (SelectItem collection) values to. I already know the values so I don't need to do all that (they are static). Need to do something like so: <select id="day" name="day"> <option value="1">Sunday</option> <option value="2">Monday</option> </select> <select id="hour" name="hour"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> All examples seem to show how to create a IEnum passing it in via the ViewData. This is in a partial, and I don't

Can't create HtmlHelper methods in VB MVC app

陌路散爱 提交于 2019-12-01 10:43:31
问题 I can't figure out what I'm missing in the following code. I've got a method that should add a (dummy) helper extension: Imports System.Runtime.CompilerServices Namespace HtmlHelpers Public Module HelpExtensions <Extension()> _ Public Function HelpMe(ByVal HtmlHelper As HtmlHelper) As String Return "<a>HELP</a>" End Function End Module End Namespace My view looks like this: <%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <%@ Import

Creating Html Helper Method - MVC Framework

夙愿已清 提交于 2019-12-01 08:56:34
问题 I am learning MVC from Stephen Walther tutorials on MSDN website. He suggests that we can create Html Helper method. Say Example using System; namespace MvcApplication1.Helpers { public class LabelHelper { public static string Label(string target, string text) { return String.Format("<label for='{0}'>{1}</label>", target, text); } } } My Question under which folder do i need to create these class? View folder or controller folder? or can i place it in App_Code folder? 回答1: I would create a

ASP.NET MVC Html.ActionLink result URL - the way of encoding

痞子三分冷 提交于 2019-12-01 05:38:51
I create an amount of actions in MVC controllers. public ActionResult DoSmth1(string token) public ActionResult DoAnother2(string token) And when I have to call ActionLink.. =Html.ActionLink<SomeController>( x=> x.DoSmth(item.property), item.property) =Html.ActionLink<AnotherController>( x=> x.DoAnother(item.property), item.property) ...it generates me different URLs: /Some/DoSmth/stringvalue /Another/DoAnother?property=stringvalue Where to set the way it builds an URL? I am alr have no ideas...(( OK, a got some waylight: - if the property names are the same that used in routing schema - eg

Does Html.TextBox uses Request.Params instead of Model?

五迷三道 提交于 2019-12-01 05:34:07
I have a simple test application: Model: public class Counter { public int Count { get; set; } public Counter() { Count = 4; } } Controller: public class TestController : Controller { public ActionResult Increment(Counter counter) { counter.Count++; return View(counter); } } View: <form action="/test/increment" method="post"> <input type="text" name="Count" value="<%= Model.Count %>" /> <input type="submit" value="Submit" /> </form> Clicking Submit I get such values: 5, 6, 7, 8, ... With Html.TextBox I expected the same behaviour <form action="/test/increment" method="post"> <%= Html.TextBox(