【c# – 使用MVC4的Ninject – 绑定bin文件夹中的所有程序集】教程文章相关的互联网学习教程文章

C#MVC4怎么实现全选checkbox。_html/css_WEB-ITnose

mvc4 C# MVC4 怎么实现全选checkbox。 回复讨论(解决方案) $("#chkAll").click(function () { if (this.checked) { $("input[name=chkId]").each(function () { this.checked = true; }); } else { $("input[name=chkId]").each(function () { this.checked = false; }); } }); 全选 window.onload = f...

使用C#MVC4读取RSS Feed【代码】

这是我的第一篇文章.因此,我遇到了这个问题,并且对这种语言或C#还是陌生的. 我有一个读取新闻rss的模型,然后使用相同的索引控制器将其传递给视图. 这是我的模型:using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Web; using System.Xml.Linq;namespace Fantacalcio.Web.Areas.Admin.Models {public class FeedGazzetta{public string Title { get; set; }public string Descr...

c#-有条件地在html.RadioButtonFor(MVC4 / Razor)中包含选中的属性【代码】

当您在手动编码的html元素(例如单选按钮)中明确包含选中的属性时,可以使用bool来确定该属性是否将完全存在于该元素上as seen here.对于那些不想单击链接并为该人提供一些当之无愧的流量的人: @ { 布尔同意= true;}<输入类型=“复选框”名称=“同意”值=“同意”选中=“ @同意” /> 但是,可以说我要对对象使用@ Html.RadioButtonFor().不会发生相同的情况. @ Html.RadioButtonFor(m => m.Property,“ ValueOfTextBox”,新的{@id...

c#-在MVC4中使用编辑器模板提交后,未正确填充回发对象【代码】

按下“提交”按钮后找回帖子时,我遇到了MVC4和编辑器模板的麻烦.这是我的模型:public class Form {public Form(){this.Rows = new List<Row>();}public List<Row> Rows { get; set; }public int Id { get; set; } }public class Row {public Row(){this.Label = string.Empty;this.Type = string.Empty;}public string Label { get; set; }public string Type { get; set; }public int Id { get; set; } }public class SimpleRow ...

C#-文件上传在ASP.NET MVC4中不起作用-移动模板【代码】

我正在将C#和ASP.NET MVC4用于Web应用程序(移动模板). 现在,我的视图中包含以下代码:@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })){ <label for="file">Upload:</label><input type="file" name="file" id="file"/><input type="submit" value="Upload" />}这在我的控制器中:[HttpPost]public ActionResult Index(HttpPostedFileBase file){string path = System.IO.Pat...

C#-ASP.NET MVC4代码优先-数据验证不起作用【代码】

我在表单中进行数据验证时遇到问题.我在模型中声明了错误消息,但似乎在View中没有任何作用.我有以下模型:public class Dog {[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)][Display(Name = "Id")]public int Id { get; set; }[Display(Name = "Name")][StringLength(20)]public string Name { get; set; }[Display(Name = "Value")][Range(1, int.MaxValue, ErrorMessage="Minimum value is 1")]public int Value {...

c#-在MVC4中的DropDownListFor()上未设置所选值【代码】

看来这个问题被问了太多次了.但是,这让我发疯. 这是我的(简化)模型.public class UserEditModel {[Required]public string Title { get; set; }private IEnumerable<SelectListItem> _titleList;public IEnumerable<SelectListItem> TitleList{get { return _titleList.Select(x => new SelectListItem {Selected = (x.Value == Title), Text = x.Text,Value = x.Value});}set { _titleList = value; }} }TitleList成员中每个Selec...

c#-mvc4-db.SaveChanges()-十进制值超出范围【代码】

我正在构建一个MVC4应用程序,该应用程序要求我在“创建”新记录时生成21位数字的密钥. 这是我定义数据库列的上下文:public class cust{public int ID { get; set; }public decimal CPCUST_KEY { get; set; }public decimal CPCUST_TOKEN { get; set; }public decimal CPCUST_ALTERNATE_KEY { get; set; }在我的SQL Server表中,所有项目均设置为’decimal(38,0)’…我相信我应该使用十进制数据类型?不知何故,我仍然超出以下范围错...

C#-MVC4的TreeView

我试图在MVC 4应用程序中以树视图的形式显示我的数据.但是我是MVC的新手,所以也许有人可以推荐一些分步教程,介绍如何在MVC 4中使用这种树形视图? 谢谢.解决方法:在MVC中没有像这样的“即用型”控件.您应该为此使用一个Jquery插件. 在这里看看: 更新的链接: http://bassistance.de/jquery-plugins/jquery-plugin-treeview/

c#-在mvc4中Global.asax中的会话超时时重定向【代码】

我正在尝试检测会话何时结束,然后在全局asax文件中完成此操作后将用户重定向到主页. 我正在使用下面的代码,我发现here global.asax:protected void Session_Start(){if (Context.Session != null){if (Context.Session.IsNewSession){string sCookieHeader = Request.Headers["Cookie"];if ((null != sCookieHeader) && (sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0)){//intercept current routeHttpContextBase currentCon...

c# – 启动MVC4基本模板项目

我正在尝试使用基本模板启动一个新的MVC4 C#项目,当我调试项目时,我得到“无法找到资源”错误,我将如何修复此问题,以便我只显示一个我可以处理的空白页面? 提前致谢.解决方法:“基本”模板中没有任何控制器或视图.您必须至少为要显示的页面创建HomeController和关联视图.如果您希望从一个示例应用程序开始,无需添加任何内容即可查看,请选择“Internet应用程序”模板.它创建一个默认的HomeController和Index视图以及帐户登录页面.

c# – 简写如果没有其他在Razor视图中(ASP.NET MVC4)【代码】

我试图检查一个布尔值,然后显示一个整数:@( ViewBag.HaveBeenHere ? submission.DurationInMonths )我收到一个错误:CS1003: Syntax error, ‘:’ expected我知道:是为了别的,但在这种情况下,我没有其他的. 当我像这样添加它:@( ViewBag.HaveBeenHere ? submission.DurationInMonths : "" )我收到此错误:CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between ‘int’...

c# – 如何在MVC4项目中调用/引用外部web api项目【代码】

我是Web API&的新手. MVC我创建了新的WEB API& MVC解决方案单独现在我想在MVC中引用Web API动作方法,所以对于我写的下面的代码, Web Api Project Side, using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Data; using System.Net.Http; using System.Web.Http; using AttributeRouting.Web.Mvc; using RegisterStudent_WebAPI.Models;namespace Register_Student_WebAPI.Contro...

c# – 在MVC4中多次单击按钮打开弹出窗口时出现问题?【代码】

嗨,我点击按钮多次打开弹出窗口时遇到问题.我会清楚地解释我的问题.嗨,这是我的父视图客户表单.如果我输入客户名称地址类型,街道,位置,地点,然后选择区域,我在区域附近有一个添加按钮.如果区域不在列表中则表示我必须添加.所以我点击该添加按钮,它将打开AreaPartial视图作为弹出窗口.输入详细信息并单击“创建”按钮后,它将数据保存在数据库中,当它关闭时显示相同的弹出窗口,这意味着当我单击x标记[在弹出窗口的右上角时).现在一切...

c# – 设置和获取cookie asp.net mvc4【代码】

我正在尝试在我正在使用asp.net mvc4的项目中设置并获取cookie. 这就是我设置cookie的方式:var Username = new HttpCookie("Username");Username.Value = model.UserName;Username.Expires = DateTime.Now.AddDays(7);Username.Secure = true;Response.Cookies.Add(Username);然后,在其他控制器操作中,我正在尝试这个:HttpCookie cookie = Request.Cookies["Username"];但是我为那个特定的cookie得到了null.此外,我不知道这是否会...