
C# Asp.net
NewsSeaSky
乐观、积极、正直
展开
-
读取硬盘信息DriveInfo
DriveInfo是微软系统自带的类可以通过引用 using System.IO 来获得。private void Form1_Load(object sender, EventArgs e) { // Get a DriveInfo object for each drive on the system DriveInfo[] drives = DriveInfo.GetDri原创 2007-08-21 08:41:00 · 734 阅读 · 0 评论 -
asp.net内置对像应用2
5、统计ip地址登录次数 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int lastVisitCounter; if (Request.Cookies["lastVisitCounter"]原创 2007-08-28 10:42:00 · 283 阅读 · 0 评论 -
Gridview基础应用4
10、根据条件设置每行显示的颜色 GridView1.DataSource = myds; GridView1.DataBind(); for (int i = 0; i { DataRowView mydrv = myds.Tables["tb_StuResult"].DefaultView[i]; st原创 2007-08-27 09:15:00 · 324 阅读 · 0 评论 -
数据绑定技术3
7、绑定到dropdownlist控件 if (!IsPostBack) { ArrayList ListItem = new ArrayList(); ListItem.Add("1月1日,元旦"); ListItem.Add("2月14日,情人节"); ListItem.Add("3原创 2007-08-27 11:34:00 · 454 阅读 · 0 评论 -
ADO.NET基础应用3
4、access数据库备份 if (!File.Exists(Server.MapPath(@"~/bakDataBase/" + TextBox1.Text))) { File.Copy(Server.MapPath(@"~/App_Data/Test.mdb"), Server.MapPath(@"~/bakDataBase/" + TextBox1.原创 2007-08-27 22:59:00 · 334 阅读 · 0 评论 -
asp.net内置对像应用
1、response.redirect()方法 DataSet ds = new DataSet(); if (!(ds.Tables.Count { Response.Redirect("NavigatePage.aspx?UserName=" + Login1.UserName.ToString ()); }原创 2007-08-28 10:36:00 · 308 阅读 · 0 评论 -
将15位身份转换18位
protected void btnChange_Click(object sender, EventArgs e) { if (this.txtInPut.Text.Length { Response.Write("alert(请输入15位身份证号码!);location=Default.aspx"); }原创 2007-08-28 10:49:00 · 371 阅读 · 0 评论 -
C#中office的应用1
1、使用office组建创建立体统计图形using System.Data.SqlClient; //添加引用using Microsoft.Office.Interop.Owc11; //****************************后台程序 //连接数据库并获取特定字符串 string strSeriesName = "图例 1"; str原创 2007-08-29 08:48:00 · 389 阅读 · 0 评论 -
C#中office的应用2
2、导出excelusing System.IO;using System.Text; protected void Button1_Click(object sender, EventArgs e) { Export("application/ms-excel", "学生信息报表.xls"); } private void Export(string F原创 2007-08-29 08:59:00 · 373 阅读 · 0 评论 -
运算符
1、checked 和unchecked 运算符C#提供checked 和unchecked 运算符。如果把一段代码块标记为 checked ,CLR就会执行溢出检查,如果发生溢出,就抛出异常。unchecked 与之相反。 byte b=255;checked...{ b++;}Console.writeLine(b.tostring()); 2、is运算符可以检原创 2007-09-02 20:34:00 · 384 阅读 · 0 评论 -
一些.Net技巧
1. 如何获得系统文件夹使用System.Envioment类的GetFolderPath方法;例如:Environment.GetFolderPath( Environment.SpecialFolder.Personal )2. 如何获得正在执行的exe文件的路径1) 使用Application类的ExecutablePath属性2) System.Reflection.Assembly.Ge原创 2007-09-02 21:05:00 · 358 阅读 · 0 评论 -
类、字段、属性简述
一、关键字 1、internal 只能在当前项目中使用,同一命名空间内 2、public 可以在任何地方使用,没有使用限制 3、pravite 只能在类本身进行访问,子类和外面的类都不能访问 4、protected 只有本身和子类可以访问 5、abstract 类本身不能被实例,只能继承、 6、sealed 不能派生,只能实例化 7、partial 部分类修饰符 ,一个类的内容可以写原创 2007-10-23 17:10:00 · 773 阅读 · 0 评论 -
构建可以复制的类
1、浅复制 需要一种方法在一个可能引用其他类型的数据上执行浅复制操作。定义:浅复制:指复制对象的字段与原对象引用相同的对象。可增加Clone方法。 class Program { static void Main(string[] args) { ShallowClone myShallow = new ShallowClone()原创 2007-10-24 16:16:00 · 372 阅读 · 0 评论 -
类型的排序、搜索
一种数据类型将存储为数组或ArrayList中的元素,希望使用Array.Sort和ArrayList.Sort方法对数组中的这种数据类型完成定制排序。此外,可能需要在一个SortedList集合中使用这个类型。 通过在类或结构上实现IComparable接口,可以利用Array、ArrayList、 List和SortedList类的排序例程。排序算法内置在这些类中;你要做的只是告诉它们如原创 2007-10-25 08:49:00 · 382 阅读 · 0 评论 -
迭代器
迭代器的定义是,它是一个代码块,按顺序提供了要在foreach循环中使用的所有值。在 C# 1.1 中,您可以使用 foreach 循环来遍历诸如数组、集合这样的数据结构:string[] cities = {"New York","Paris","London"};foreach(string city in cities){ Console.WriteLine(city);}实际上,原创 2007-10-25 14:11:00 · 348 阅读 · 0 评论 -
数据绑定技术1
1、xml数据绑定到gridviewDataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("News.xml")); GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind();2、xml数据绑定到treeview原创 2007-08-27 10:34:00 · 488 阅读 · 0 评论 -
Gridview基础应用6
介绍扩展GridView控件:固定指定行、指定列,根据RowType固定行,根据RowState固定行使用方法(设置FixRowColumn复合属性): FixRowType - 需要固定的行的RowType(用逗号“,”分隔)FixRowState - 需要固定的行的RowState(用逗号“,”分隔)FixRows - 需要固定的行的索引(用逗号“,”分隔)FixColumns - 需要固转载 2007-08-27 10:10:00 · 344 阅读 · 0 评论 -
gridview基础应用5
13、合并表头//后台程序 protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //第一行转载 2007-08-27 09:24:00 · 335 阅读 · 0 评论 -
Console类
Console.writeLine(); 向控制台写入信息,Console.write();Console.ReadLine();设置标题Console.Title=Console.ReadLine();可能的最大高度和宽度Console.LargestWindowHeightConsole.LargestWindowWidthConsole.WindowWidt原创 2007-08-21 09:44:00 · 364 阅读 · 0 评论 -
文件解压缩GZipStream
。。。。。。 using System.IO;using System.IO.Compression; //压缩文件 public void CompressFile ( string sourceFile, string destinationFile ) { // make sure the source file is there原创 2007-08-21 08:51:00 · 971 阅读 · 0 评论 -
网络接口对象
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Net;using System.Net.Networ原创 2007-08-21 16:22:00 · 387 阅读 · 0 评论 -
字符串的收索替换
using System.IO;using System.Text.RegularExpressions;private void TestExpression(string testExpression.)// 收索串表达式 { // Create the regex options and assign the options Regex regex = new Regex(原创 2007-08-22 10:28:00 · 403 阅读 · 0 评论 -
显示执行的过程的详细信息
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using System.I原创 2007-08-23 11:44:00 · 323 阅读 · 0 评论 -
数据访问异步技术The first technique is polling.
Application.DoEvents(); // Clear all the form controls before this runs ClearControls(); // Get the data // Use the new StopWatch class to keep track of the performance // of using this tech转载 2007-08-23 16:56:00 · 284 阅读 · 0 评论 -
数据异步访问技术The third method uses WaitHandles to process results as they complete
ClearControls(); Application.DoEvents(); // Create a new StopWatch object Stopwatch myWatch = new Stopwatch(); Stopwatch mySecondWatch = new Stopwatch(); //转载 2007-08-23 17:12:00 · 319 阅读 · 0 评论 -
Gridview基础应用1
1、gridview控件实现自动编号protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e){ if (e.Row.RowIndex!=-1) { int id= e.Row.Rowindex+1; e.Row.Cells[0].Text=id.ToString(); }}原创 2007-08-24 10:53:00 · 406 阅读 · 0 评论 -
利用smtp服务发送电子邮件
//引用using System.Net;using System.Net.Mail;using System.Net.Mime; protected void btnSend_Click(object sender, EventArgs e) { string file = Server.MapPath("testXML.xml"); MailMessag原创 2007-08-28 10:53:00 · 1223 阅读 · 0 评论 -
C#预处理器指令
C#包含许多预处理器指令,这些命令从来不会被转化为可执行代码中的命令,但会影响编译过程的各个方面。;例如,使用预处理器指令 可以禁止编译代码的某一部分。另外在编写提供调式信息的代码时,也可以使用预处理器指令。预处理器指令的开头都有符号#。1、#define和#undef用法 #define DEBUG,它告诉编译器存在给定的名称的符。这点类似声明一个变量,但这个变量并没有真正的值,只是存原创 2007-08-29 15:47:00 · 424 阅读 · 0 评论 -
数据绑定技术2
4、Label 绑定变量//前台 " Font-Names="隶书" ForeColor="Red">原创 2007-08-27 11:06:00 · 337 阅读 · 0 评论 -
ado.net基础应用
1、将图片以二进制格式存储 try { string ImgPath = FileUpload1.PostedFile.FileName; string ImgName = ImgPath.Substring(ImgPath.LastIndexOf("//") + 1); string Im原创 2007-08-27 22:00:00 · 281 阅读 · 0 评论 -
GridView基础应用2
4、gridview控件中自动求和protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex >= 0) { sum += Convert.ToInt32(e.Row.Cells[4].Text);原创 2007-08-25 18:44:00 · 313 阅读 · 0 评论 -
Gridview基础应用3
7、分页控制 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } 8、实现gridview控件中夸页面多选原创 2007-08-25 19:14:00 · 370 阅读 · 0 评论 -
.Net 平台概述
1、.net framework结构主要包括四大部分(1) 使用通用语言执行环境(Common language Runtime)(2)类函数库(3)程序语言(4)visual 松土地哦.net2、Dot Net 环境的新特性(1)使用统一的Internet标准(如XML)将不同的系统对接(2)这是Internet上首个大规模的高度分布应用服务框架(3)使用了一个名原创 2007-10-16 09:42:00 · 1527 阅读 · 0 评论