惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
罗磊的独立博客
The GitHub Blog
The GitHub Blog
L
LangChain Blog
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
DataBreaches.Net
宝玉的分享
宝玉的分享
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
N
Netflix TechBlog - Medium
The Cloudflare Blog
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
美团技术团队
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog

博客园 - 荆棘鸟

FSO查看文件夹 鼠标事件 《《未完》》 不间断往上滚动 超酷的日历[经典] 右下角弹出提示的代码!!!经典 屏蔽源码 效果怎么样 一个类似于QQ菜单的导航[经典] 滑出式菜单导航栏 js翻页代码集合 [经典] 一个JS的翻页效果(翻书效果) sql常用语句 菜鸟的最爱 .NET经典代码汇总(五) 菜鸟的最爱 .NET经典代码汇总(四) 菜鸟的最爱 .NET经典代码汇总(三) 菜鸟的最爱 .NET经典代码汇总(二) 值传递 Server.Transfer与Response.Redirect页面跳转方法的区别,总合一下 .net下使用cookies
菜鸟的最爱 .NET经典代码汇总(一)
荆棘鸟 · 2007-11-01 · via 博客园 - 荆棘鸟

菜鸟的最爱 .NET经典代码汇总(一)

  程序的学习是一个循序渐进的过程,一些常用的或经典代码应该保存下来以便日后使用。本文就给出一些.net的经典代码,希望对大家有所帮助…… 

  1.弹出对话框.点击转向指定页面

  Response.Write(""); 
  Response.Write("");
  2.弹出对话框

  Response.Write("");
  3.删除文件

  string filename ="20059595157517.jpg";
pub.util.DeleteFile(HttpContext.Current.Server.MapPath("../file/")+filename);
  4.绑定下拉列表框datalist

  System.Data.DataView dv=conn.Exec_ex("select -1 as code,'请选择经营模式' as content from dealin union select code,content from dealin"); 
  this.dealincode.DataSource=dv; 
  this.dealincode.DataTextField="content"; 
  this.dealincode.DataValueField="code"; 
  this.dealincode.DataBind(); 
  this.dealincode.Items.FindByValue(dv[0]["dealincode"].ToString()).Selected=true;
  5.时间去秒显示

<%# System.DateTime.Parse(DataBinder.Eval(Container.DataItem,"begtime").ToString()).ToShortDateString()%>
  6.标题带链接

<%# "<a class="12c" target="_blank" href="http://www.webjx.com/CV/_"+DataBinder.Eval(Container.DataItem,"procode")+".html">"+ DataBinder.Eval(Container.DataItem,"proname")+"</a>"%>
  7.修改转向

<%# "<A href="editpushpro.aspx?id="+DataBinder.Eval(Container.DataItem,"code")+"">"+"修改"+"</A>"%>
  8.弹出确定按钮

<%# "<A id="btnDelete" onclick="return confirm('你是否确定删除这条记录吗?');" href="pushproduct.aspx?dl="+DataBinder.Eval(Container.DataItem,"code")+" ">"+"删除"+"</A>"%>
  9.输出数据格式化 "{0:F2}" 是格式 F2表示小数点后剩两位

<%# DataBinder.Eval(Container, "DataItem.PriceMoney","{0:F2}") %>
  10.提取动态网页内容

  Uri uri = new Uri("http://www.webjx.com/"); 
  WebRequest req = WebRequest.Create(uri); 
  WebResponse resp = req.GetResponse(); 
  Stream str = resp.GetResponseStream(); 
  StreamReader sr = new StreamReader(str,System.Text.Encoding.Default); 
  string t = sr.ReadToEnd(); 
  this.Response.Write(t.ToString()); 
关键词:.NET,经典,汇总