为什么我用字母串下划线得到错误"Expected class,interface,enum or struct"?
public static string IsSelected(this HtmlHelper helper, string A, string B)
{
return "wtf";
}
Run Code Online (Sandbox Code Playgroud) 我确定我正在做一些非常愚蠢的事情,但我已经为我的应用程序的一个部分创建了一个嵌套的站点主机.
我得到了额外的文字,就像它应该在新的Site Master(Greek.Master)上一样.但是当我去为Greek.Master添加一些Html时,我发现html助手不起作用.
这是我的嵌套大师
<%@ Master Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true"
CodeBehind="Greek.master.cs" Inherits="PaleLocust.Views.Greek.Greek" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="column">
</div>
<asp:ContentPlaceHolder ID="GreekMain" runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
如果我尝试在div或GreekMain内容中执行<%= Html ....%>,它不会显示在intellisense中并导致错误消息.
它适用于原始的Site.Main(此时是ASP.NET MVC的默认版本).
所以,我错过了一些东西(可能是显而易见的),或者有没有办法让这个帮手去?
谢谢
我正在尝试通过以下代码创建输入文本,以便它可以保存用户可以在日期选择器jQuery控件中选择的日期:
<%: Html.TextBox("date", null, new {class = "date-pick"}) %>
<input name="date" id="date" class="date-pick" />
Run Code Online (Sandbox Code Playgroud)
问题是,我需要为输入文本指定"class"属性,但"class"当然是C#中的保留keword :-)
有没有办法使用这个覆盖?
谢谢!
这是我视图的片段,它给了我错误
@model MembershipUserCollection
@{
ViewBag.Title = "Index";
}
@{var usersGrid = new WebGrid(source: Model, rowsPerPage: 40);}
Run Code Online (Sandbox Code Playgroud)
显然,WebGrid构造函数不接受MembershipUserCollection作为参数.我怎么能绕过这个?
请帮忙.我需要在用户列表中添加分页.
asp.net-mvc asp.net-membership html-helper webgrid asp.net-mvc-3
我有一个模特
public class Person {
public string Name { get; set; }
public int Age { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和一个简单的视图
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IList<Site.Models.Person>>" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<% for (int i = 0 ; i < Model.Count ; i++) { %>
<%: Html.DisplayFor(m => m[i])%>
<% } %>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
部分视图
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Site.Models.Person>" %>
<h1>A person</h1>
<div>Name: <%: Html.DisplayFor(x => x.Name)%></div>
<div>Age: <%: Html.DisplayFor(x => x.Age)%></div>
Run Code Online (Sandbox Code Playgroud)
和单个控制器
public ActionResult Index () {
Person …Run Code Online (Sandbox Code Playgroud) 我对@的使用有点困惑.在下面的代码中我首先编写Html.ActionLink(...)而不是@Html.ActionLink(...)因为我在一个if块(C#代码).因此,我想确切地了解何时必须使用@以及何时不必使用它.
<td width="32%" align="center">
@if (Model.SeccionImpresos != null)
{
@Html.ActionLink("IMPRESOS", "Index", "Trabajo", null, null, "#impresos", new { id = Model.Id }, null);
}
</td>
Run Code Online (Sandbox Code Playgroud)
我对此有所帮助.
我有网站模板并将其用于我的网站.我是asp.net mvc 3和razor的新手.使用html helper修改html标签非常困难.如何使用ActionLink Helper将span标记放在锚标记之间.我使用razor和html helper来生成链接.我想生成以下标签:
<li><a href="Account/LogOff" title="Logout"><span class="glyph logout"></span> Logout</a></li>
Run Code Online (Sandbox Code Playgroud)
我试过这个
<li>@Html.ActionLink("<span class='glyph logout'></span> Log out", "LogOff", "Account") </li>
Run Code Online (Sandbox Code Playgroud)
我很困惑如何做到这一点.这不是将span标记生成为字符串的正确方法.如何生成正确的标签.
我正在开发一个asp.net mvc web应用程序,在我的高级搜索页面上,我想要有三个html.dropdownlist包含静态值: -
完全符合
从...开始
我需要下拉列表在任何搜索字段旁边.
那么任何一个建议如何我可以创建这样的静态html.dropdownlist,因为我所拥有的所有当前下拉列表都填充了我的模型中的动态数据?
谢谢
我想动态地向我的表添加行,如下所示:
var tableRef = document.getElementById('tblData').getElementsByTagName('tbody')[0];
var newRow = tableRef.insertRow(tableRef.rows.length);
var newCell = newRow.insertCell(0);
newCell.appendChild(document.createElement('input'));
var newCell = newRow.insertCell(1);
newCell.appendChild('@Html.DropDownList("AppVersionGroupId", string.Empty)');
Run Code Online (Sandbox Code Playgroud)
但输出是:
newCell.appendChild('<select id="AppVersionGroupId" name="AppVersionGroupId"><option value=""></option>
<option value="46a08053-56e3-4320-aec3-7b521cca28ab">op1</option>
<option value="36ff6b7a-bdef-4506-b771-95cc42cd2667">op2</option>
<option value="e84fcfc5-8a46-47fd-8584-c00a5642f246">op3</option>
</select>');
Run Code Online (Sandbox Code Playgroud)
我怎么能用html.!!! 在我的JavaScript中?
我有一个注册表单,我试图在其中放置Html.EditorFor()。
例如:
@ModelType RegisterViewModel
<othermarkup />
<div>
@Html.LabelFor(Function(m) m.ConfirmPassword, New With {.class = "required"})
<div>
@Html.PasswordFor(Function(m) m.ConfirmPassword)
@Html.ValidationMessageFor(Function(m) m.ConfirmPassword)
</div>
</div>
<div>
@Html.EditorFor(Function(m) m.AlertSettings)
</div>
<othermarkup />
Run Code Online (Sandbox Code Playgroud)
RegisterViewModel包含一个名为AlertSettings的属性(类型为AlertSettingsViewModel),AlertSettingsViewModel.vbhtml的编辑器模板如下所示:
@ModelType AlertSettingsViewModel
<othermarkup />
<div class="panel-heading">Personalized Alert Settings</div>
<div class="panel-body">
<div class="col-sm-6">
<div>
<label for="Disciplines">Disciplines</label>
@Html.ValidationMessageFor(Function(m) m.Disciplines)
@Html.CheckBoxListFor(Function(m) m.Disciplines, SelectLists.Disciplines())
</div>
<div class="visible-xs"><br /></div>
</div>
</div>
<othermarkup />
Run Code Online (Sandbox Code Playgroud)
AlertSettingsViewModel的Disciplines属性是一个整数数组。
我正在使用自定义的HtmlHelper生成复选框列表。它由以下两个方法组成(第一个调用第二个):
''' <summary>
''' Returns a checkbox for each of the provided <paramref name="items"/>.
''' </summary>
<System.Runtime.CompilerServices.Extension>
Public Function CheckBoxListFor(Of TModel, TValue)(htmlHelper As …Run Code Online (Sandbox Code Playgroud) html-helper ×10
asp.net-mvc ×9
razor ×2
.net ×1
asp.net ×1
c# ×1
html ×1
javascript ×1
jquery ×1
templates ×1
vb.net ×1
webgrid ×1