posted on November 9, 2011
AutoGenerateColumns='true'的GridView如何支持htmlencode/htmldecode
我们知道BoundField.HtmlEncode 属性可以设置一个单元格是否能够htmlencode,我今天碰到的问题是:自动生成列的GridView,表头可能是包含html的比如<font color=red>邮件</font>,默认被htmlencode了,而我不希望这样做,所以有了如下的代码:
我们知道BoundField.HtmlEncode 属性可以设置一个单元格是否能够htmlencode,我今天碰到的问题是:自动生成列的GridView,表头可能是包含html的比如<font color=red>邮件</font>,默认被htmlencode了,而我不希望这样做,所以有了如下的代码:
使用window.location跳转,在FF中,没问题,下一页面可以取得UrlReffer,但在IE中UrlReffer不被记录
真变态,
让我头痛了半天,弄了个丑陋的办法做了如下实现:
使用如下代码可以发送附件
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; MailAttachment attachment = new MailAttachment( Server.MapPath( "mailTest.txt" ) ); //create the attachment mail.Attachments.Add( attachment ); SmtpMail.SmtpServer = "localhost"; SmtpMail.Send( mail );
使用如下代码可以在用户上传附件后发生邮件:
今天在帮同事调程序时发现了这个死角
现象如下,没有任何输入的textarea提交到服务端后得到的值总是","
找了半天发现是因为页面上两个textarea的name相同,以前只知道页面上radio的name相同则是一个组,name相同的
的checkbox提交后是以逗号分隔值的,于是做了下面代码的试验,发现任何name相同的element提交到服务端都会得到逗号分隔的值,以前还不知道这个,汗
如何深度克隆一个对象?
普通版:
public static object CloneObject( object obj )
{
using ( MemoryStream memStream = new MemoryStream( ) )
{
BinaryFormatter binaryFormatter = new BinaryFormatter( null ,
new StreamingContext( StreamingContextStates.Clone ) );
binaryFormatter.Serialize( memStream , obj );
memStream.Seek( 0 , SeekOrigin.Begin );
return binaryFormatter.Deserialize( memStream );
}
}
泛型版:
配置大多就是文件配置或者数据库配置了
ref:
http://mnour.blogspot.com/2008/11/mvc-routing-using-custom-configuration.html
http://www.cnblogs.com/QLeelulu/archive/2008/11/24/1340212.html
http://www.iansuttle.com/blog/post/ASPNET-MVC-Store-Routes-in-the-Database.aspx
我觉得加上做webform时常用的PageAlias和BuildUrl会更好用些
ASP.NET MVC CodePlex Preview 4
Changes between Preview 3 and Codeplex Preview 4 (PDF)