11 2012 档案

摘要:开始不间断收集linq查询使用的方法,日拱一卒,月可渡江。 阅读全文
posted @ 2012-11-30 13:11 Raywang80s 阅读(259) 评论(0) 推荐(0)
摘要:Transform ASP.NET MVC3 Default Template with Twitter Bootstrap[转摘]By Aniruddha Guin, 18 Jun 2012IntroductionThe ASP.NET MVC3 default template from Visual Studio 2010 is a very useful tool for developers to create something very quickly by offering a structured project template. Twitter Bootstraphas 阅读全文
posted @ 2012-11-27 15:46 Raywang80s 阅读(1328) 评论(1) 推荐(1)
摘要:MVC中ViewBag、ViewData和TempData 的区别与联系[转减增辑]ViewData 和 TempData 都可以传递弱类型数据,区别如下:ViewData 只在当前 Action 中有效,生命周期和 View 相同;TempData 的数据至多只能经过一次Controller传递,并且每个元素至多只能被访问一次,访问以后,自动被删除。TempData 一般用于临时的缓存内容或抛出错误页面时传递错误信息,可以将TempData 在使用之前存储到相应的 ViewData 中以备循环使用。TempData 保存在Session中,Controller每次执行请求的时候,会从Sess 阅读全文
posted @ 2012-11-27 10:47 Raywang80s 阅读(441) 评论(0) 推荐(0)
摘要:1.控制器中跳转:Redirect(url) 直接跳转到URl 比如 action 里 return Redirect("http://www.baidu.com") 直接跳转到baidu.RedirectToAction("action",new{id=6,name=helloK}) 跳转到本control的另外一个action 可以带参数.2.页面跳转:Html.Actionlink("详细","action",new{id=6,name=helloK}) 跳转到control的另外一个action. 阅读全文
posted @ 2012-11-26 16:52 Raywang80s 阅读(560) 评论(0) 推荐(0)
摘要:我们可以通过使用DataTime这个类来获取当前的时间。通过调用类中的各种方法我们可以获取不同的时间:如:日期(2008-09-04)、时间(12:12:12)、日期+时间(2008-09-04 12:11:10)等。//获取日期+时间DateTime.Now.ToString(); // 2008-9-4 20:02:10DateTime.Now.ToLocalTime().ToString(); // 2008-9-4 20:12:12//获取日期DateTime.Now.ToLongDateString().ToString(); // 2008... 阅读全文
posted @ 2012-11-26 15:50 Raywang80s 阅读(507) 评论(0) 推荐(0)
摘要:Linq中Orderby使用在LINQ查询表达式中,orderby子句可以对查询结果进行排序。排序方式可以为“升序”或“降序”,且排序的键可以为一个或多个。注意:LINQ查询表达式对查询结果的默认排序方式为“升序”。实例:private void OrderQuery() { ///构建数据源 List<UserInfo> users = new List<UserInfo>(); for (int i = 1; i < 10; i++) { ... 阅读全文
posted @ 2012-11-25 21:07 Raywang80s 阅读(307) 评论(0) 推荐(0)
摘要:asp.net mvc3 MySql数据库,保存数据库乱码 修改数据库的连接字符器在连接字符串当中增加 【charset=gb2312;】应该就没有问题了。<add name="PhotographyEntities" connectionString="metadata=res://*/Models.Photography.csdl|res://*/Models.Photography.ssdl|res://*/Models.Photography.msl; provider=MySql.Data.MySqlClient; provider connect 阅读全文
posted @ 2012-11-22 16:32 Raywang80s 阅读(157) 评论(0) 推荐(0)
摘要:2012-06-04 来自:CNBLOGSAsp.net MVC 3 中Session与ViewBag传值到Javascript中, 主要方法有:1. 使用Javascript Variable假设有say _layout.cshtml<head> ... <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> @RenderSection("my_script_vari 阅读全文
posted @ 2012-11-21 10:38 Raywang80s 阅读(466) 评论(0) 推荐(1)
摘要:类似于这样的一个字段 public class BiographyDetial { [Display(Name = "员工编号")] [StringLength(15, ErrorMessage = "员工编号不能超过15个字符")] [RegularExpression(@"^[0-9]*$", ErrorMessage = "必须输入数字")] public int ID { get; set; } }create出错“/”应用程序中的服务器错误。无法将类型为“System.Int32”的对象强制转换为类型“S 阅读全文
posted @ 2012-11-19 11:28 Raywang80s 阅读(303) 评论(0) 推荐(0)
摘要:1.Html.BeginForm() 该方法用于构建一个From表单的开始,他的构造方法为: Html.BeginForm("ActionName","ControllerName",FormMethod.method) 一般构建一个表单结构如下 <% using(Html.BeginForm ("index","home",FormMethod.Post)){ %> 。。。。。。 <%} %> 他将在客户端产生一个类似<form action="/account/login 阅读全文
posted @ 2012-11-14 13:02 Raywang80s 阅读(840) 评论(0) 推荐(0)
摘要:如题:view层ui需要调用多个model实体时,可以再model层建立一个实体数据集方便前台调用。如下红色字体代码namespace GetMoney.web.Models{ public class Wenan { public int WenanId { get; set; } [Required] [DisplayName("标题")] [MaxLength(100)] public string Title { get; set; } } public class WaTyp... 阅读全文
posted @ 2012-11-12 21:32 Raywang80s 阅读(309) 评论(0) 推荐(0)
摘要:让我们来看看如何对一个整数数组使用 Single 操作符。这个整数数组的每个元素代表 2 的 1 到 10 次方。先创建此数组,然后使用 Single 操作符来检索满足 Linq Lambda表达式中指定条件的单个整数元素:int[]nums={1,2,4,8,16,32,64,128,256,512,1024}; intsingleNum=nums.Single(x=>x>16&&x<64); Console.WriteLine(singleNum.ToString());Linq Lambda表达式包含多个关键部分。Linq Lambda表达式首先定义传入 阅读全文
posted @ 2012-11-08 17:19 Raywang80s 阅读(904) 评论(0) 推荐(0)
摘要:网页内插入Js代码<style type="text/css">.eweima{width:200px;height:200px;margin:auto;float:right;}</style><div class="eweima"><script type="text/javascript">document.write("<img src=\"https://chart.googleapis.com/chart?cht=qr&chs=500x500 阅读全文
posted @ 2012-11-08 12:32 Raywang80s 阅读(407) 评论(0) 推荐(0)
摘要:编写一个类,需要添加一些引用using System.Net;using System.Text;using System.IO;代码如下 public static CookieContainer Cook = new CookieContainer(); public static string CreatRequestGetResponse(string URL, string PostData) { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(U... 阅读全文
posted @ 2012-11-07 16:59 Raywang80s 阅读(291) 评论(0) 推荐(0)
摘要:C#使用 Server.URLEncode编码 System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.Unicode);System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.UTF8);System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding("GB2312")); 解码System.Web.HttpUtility.UrlDecode(str,System.Text.En 阅读全文
posted @ 2012-11-07 16:49 Raywang80s 阅读(917) 评论(0) 推荐(0)
摘要:1: ViewData传值方式ViewData的生命周期和View相同, 只对当前View有效. ViewData["zd"] = dfdfd2:TempData传值方式 可以跨Action传递 TempData的数据至多只能经过一次Controller传递, 并且每个元素至多只能被访问一次, 例如一个用法为,抛出一个异常。跳转到error页面public ActionResult Index3(){ TempData["tempIndex"] = "出错了!"; Response.Redirect("/home/error 阅读全文
posted @ 2012-11-06 14:03 Raywang80s 阅读(772) 评论(0) 推荐(0)
摘要:一Html.ActionLink("linkText","actionName")该重载的第一个参数是该链接要显示的文字,第二个参数是对应的控制器的方法,默认控制器为当前页面的控制器,如果当前页面的控制器为Products,则Html.ActionLink("detail","Detail")则会生成<ahref="/Products/Detail">all</a>二Html.ActionLink("linkText","actionName 阅读全文
posted @ 2012-11-05 17:08 Raywang80s 阅读(305) 评论(0) 推荐(0)
摘要:使用绝对路径,不要使用相对路径 <form runat="server" method="get" action=@Url.Content("~/addtools/onpays/alipay/default.aspx") > 阅读全文
posted @ 2012-11-05 15:55 Raywang80s 阅读(144) 评论(0) 推荐(0)
摘要:使用asp.net 接收html静态页面提交的表单时,接受的函数应使用 this.Request.QueryString["userName"],不能使用string userName = this.Request.Form["userName"].ToString(); 后一种方法会提示“未将对象引用设置到对象的实例”。我的代码如下:html静态页面:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login_xhtml.aspx.c 阅读全文
posted @ 2012-11-05 11:15 Raywang80s 阅读(468) 评论(0) 推荐(1)
摘要:无法将“Enable-Migrations”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后重试。 所在位置 行:1 字符: 18 + Enable-Migrations <<<< + CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 使用PM> Update-Package命令后 阅读全文
posted @ 2012-11-04 11:22 Raywang80s 阅读(741) 评论(1) 推荐(0)
摘要:C#中调用python脚本1.安装IronPython到http://ironpython.codeplex.com/下载IronPython。安装下载下来的安装包(要先装VS啊)。2.创建项目创建一个C#的控制台应用程序。添加引用:浏览到IronPython的安装目录中,添加对IronPython.dll,Microsoft.Scripting.dll两个dll的引用。3.添加Python文件到当前的项目中创建一个文本文件命名为:hello.py,编辑如下defwelcome(name):return"hello"+name把该文件添加的当前的项目中。4.在C#中调用Py 阅读全文
posted @ 2012-11-01 15:24 Raywang80s 阅读(374) 评论(0) 推荐(0)