易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : c#

ASP.NET(C#)常用代码30例

1. 打开新的窗口并传送参数:
  传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
  接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
  2.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(’确认?’)");
button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}")
  3.删除表格选定记录
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "Delete from Employee where emp_id = " + intEmpID.ToString()
  4.删除表格记录警告
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
 switch(e.Item.ItemType)
 {
  case ListItemType.Item :
  case ListItemType.AlternatingItem :
  case ListItemType.EditItem:
   TableCell my ......

ASP.NET(C#)常用代码30例

1. 打开新的窗口并传送参数:
  传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
  接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
  2.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(’确认?’)");
button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}")
  3.删除表格选定记录
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "Delete from Employee where emp_id = " + intEmpID.ToString()
  4.删除表格记录警告
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
 switch(e.Item.ItemType)
 {
  case ListItemType.Item :
  case ListItemType.AlternatingItem :
  case ListItemType.EditItem:
   TableCell my ......

SQl Xml和C# Xml数据的一点操作总结

SQl Xml和C# Xml数据的一点操作总结
在此申明Xml是InfoSet数据不是字符串,所以在此强烈反对用string拼接xml。数据库可以存放xml类型数据,那么该数据的具体操作又如何了。
1.首先建立一张含有xml数据类型的表
CREATE TABLE [dbo].[TestXml](
 [ID] [bigint] IDENTITY(1,1) NOT NULL,
 [Message] [xml] NULL,
 CONSTRAINT [PK_TestXml] PRIMARY KEY CLUSTERED
(
 [ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
2.创建相应的DataSet
注意默认Message是String类型,为此我们要把它改为XDocument或则XmlDocument,如:
 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public XDocument Message {
                get {
                    try {
               ......

SQl Xml和C# Xml数据的一点操作总结

SQl Xml和C# Xml数据的一点操作总结
在此申明Xml是InfoSet数据不是字符串,所以在此强烈反对用string拼接xml。数据库可以存放xml类型数据,那么该数据的具体操作又如何了。
1.首先建立一张含有xml数据类型的表
CREATE TABLE [dbo].[TestXml](
 [ID] [bigint] IDENTITY(1,1) NOT NULL,
 [Message] [xml] NULL,
 CONSTRAINT [PK_TestXml] PRIMARY KEY CLUSTERED
(
 [ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
2.创建相应的DataSet
注意默认Message是String类型,为此我们要把它改为XDocument或则XmlDocument,如:
 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public XDocument Message {
                get {
                    try {
               ......

SQl Xml和C# Xml数据的一点操作总结

SQl Xml和C# Xml数据的一点操作总结
在此申明Xml是InfoSet数据不是字符串,所以在此强烈反对用string拼接xml。数据库可以存放xml类型数据,那么该数据的具体操作又如何了。
1.首先建立一张含有xml数据类型的表
CREATE TABLE [dbo].[TestXml](
 [ID] [bigint] IDENTITY(1,1) NOT NULL,
 [Message] [xml] NULL,
 CONSTRAINT [PK_TestXml] PRIMARY KEY CLUSTERED
(
 [ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
2.创建相应的DataSet
注意默认Message是String类型,为此我们要把它改为XDocument或则XmlDocument,如:
 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public XDocument Message {
                get {
                    try {
               ......

用C#开发批量ACCESS数据库压缩程序

下面给出了使用C# 开发的一个压缩ACCESS数据库的程序
像FolderBrowserDialog(用于浏览选择文件夹的对话框)、MessageBox(消息处理对话框)、DirectoryInfo(目录信息,可用于创建、检测是否存在等对目录的操作)、FileInfo(文件信息,可用于文件的检测、文件信息的获取、复制等操作)、DataGridView(数据表格控件,用于显示文件信息列表数据)、DataRowView(对一些数据源信息进行筛选,排序)、System.Diagnostics.Process.Start(启动其它程序打开文件夹目录),下面就依次介绍一下在此软件开发中我都使用到以上控件、对象的哪些内容。
一、FolderBrowserDialog(文件夹浏览对话框),在此软件中用于打开选择数据库根目录或打开创建、选择备份目录,下面是两处位置的代码详细介绍。
1.选择数据库目录,在此处不需要新建文件夹,因此屏蔽新建文件夹按钮。
C#代码
         FolderBrowserDialog df = new FolderBrowserDialog();   
  
   //设置文件浏览对话框上的描述内容   
           ......

用C#开发批量ACCESS数据库压缩程序

下面给出了使用C# 开发的一个压缩ACCESS数据库的程序
像FolderBrowserDialog(用于浏览选择文件夹的对话框)、MessageBox(消息处理对话框)、DirectoryInfo(目录信息,可用于创建、检测是否存在等对目录的操作)、FileInfo(文件信息,可用于文件的检测、文件信息的获取、复制等操作)、DataGridView(数据表格控件,用于显示文件信息列表数据)、DataRowView(对一些数据源信息进行筛选,排序)、System.Diagnostics.Process.Start(启动其它程序打开文件夹目录),下面就依次介绍一下在此软件开发中我都使用到以上控件、对象的哪些内容。
一、FolderBrowserDialog(文件夹浏览对话框),在此软件中用于打开选择数据库根目录或打开创建、选择备份目录,下面是两处位置的代码详细介绍。
1.选择数据库目录,在此处不需要新建文件夹,因此屏蔽新建文件夹按钮。
C#代码
         FolderBrowserDialog df = new FolderBrowserDialog();   
  
   //设置文件浏览对话框上的描述内容   
           ......

Sqlite在C#中的应用

在 .NET 里面使用 SQLite, 我这里使用的wrapper是 System.Data.SQLite,它只需要一个dll,接口符合ADO.Net 2.0的定义,性能也不错,NHibernate用的也是它,目前支持ADO.NET 3.5了,支持集成在 VS2005 和 VS2008里面,而且支持wince,是个亮点
因为符合ADO.NET的规范,所以使用方式,基本和 SqlClient, OleDb等原生的一致
using System.Data;
using System.Data.SQLite;
//...
using (SQLiteConnection cn = new SQLiteConnection(
    "Data Source=Test.db3;Pooling=true;FailIfMissing=false")
    )
//Pooling设置为true时,SQL连接将从连接池获得,如果没有则新建并添加到连接池中,默认是true。
//FailIfMissing默认为false,如果数据库文件不存在,会自动创建一个新的,若设置为true,将不会创建,而是抛出异常信息。
{
    //在打开数据库时,会判断数据库是否存在,如果不存在,则在当前目录下创建一个
    cn.Open();
    using (SQLiteCommand cmd = new SQLiteCommand())
    {
        cmd.Connection = cn; ......

Sqlite在C#中的应用

在 .NET 里面使用 SQLite, 我这里使用的wrapper是 System.Data.SQLite,它只需要一个dll,接口符合ADO.Net 2.0的定义,性能也不错,NHibernate用的也是它,目前支持ADO.NET 3.5了,支持集成在 VS2005 和 VS2008里面,而且支持wince,是个亮点
因为符合ADO.NET的规范,所以使用方式,基本和 SqlClient, OleDb等原生的一致
using System.Data;
using System.Data.SQLite;
//...
using (SQLiteConnection cn = new SQLiteConnection(
    "Data Source=Test.db3;Pooling=true;FailIfMissing=false")
    )
//Pooling设置为true时,SQL连接将从连接池获得,如果没有则新建并添加到连接池中,默认是true。
//FailIfMissing默认为false,如果数据库文件不存在,会自动创建一个新的,若设置为true,将不会创建,而是抛出异常信息。
{
    //在打开数据库时,会判断数据库是否存在,如果不存在,则在当前目录下创建一个
    cn.Open();
    using (SQLiteCommand cmd = new SQLiteCommand())
    {
        cmd.Connection = cn; ......

VB.NET/C# and JavaScript communication

Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required data transfer between my VB.NET WinForms application and the JavaScript (inside an HTML page). Along the way, I hit certain problems, and trying to resolve them cost plenty of time on the web (on Google mostly), so I thought of this article as a platform for developers looking to sort out similar issues. There isn't much detail on this topic on the web apart from a couple of Hello World examples from Microsoft on MSDN.
Starting point
OK, without any further talk, I will dig in to the subject.
Hello World
To start off, we'll start with a very simple example; all this will do is call a JavaScript function from VB.NET to display an alert with message 'Hello world'. Similarly, from the HTML pag ......

VB.NET/C# and JavaScript communication

Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required data transfer between my VB.NET WinForms application and the JavaScript (inside an HTML page). Along the way, I hit certain problems, and trying to resolve them cost plenty of time on the web (on Google mostly), so I thought of this article as a platform for developers looking to sort out similar issues. There isn't much detail on this topic on the web apart from a couple of Hello World examples from Microsoft on MSDN.
Starting point
OK, without any further talk, I will dig in to the subject.
Hello World
To start off, we'll start with a very simple example; all this will do is call a JavaScript function from VB.NET to display an alert with message 'Hello world'. Similarly, from the HTML pag ......

VB.NET/C# and JavaScript communication

Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required data transfer between my VB.NET WinForms application and the JavaScript (inside an HTML page). Along the way, I hit certain problems, and trying to resolve them cost plenty of time on the web (on Google mostly), so I thought of this article as a platform for developers looking to sort out similar issues. There isn't much detail on this topic on the web apart from a couple of Hello World examples from Microsoft on MSDN.
Starting point
OK, without any further talk, I will dig in to the subject.
Hello World
To start off, we'll start with a very simple example; all this will do is call a JavaScript function from VB.NET to display an alert with message 'Hello world'. Similarly, from the HTML pag ......

C#代码与javaScript函数的相互调用

C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
  问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;
  2、在前台写一个js函数,内容为document.getElementById("btn1").click();
  3、在前台或后台调用js函数,激发click事件,等于访问后台c#函数;
方法二:1、函数声明为public  
  后台代码(把public改成protected也可以)
  public string ss()
  {
  return("a");
  }
  2、在html里用可以调用
  前台脚本
  < language=javascript>
  var a = "";
  alert(a);
 
方法三:1、< language="javascript">
 
 
 
方法四:< language="javascript">
function SubmitKeyClick() ......

C#代码与javaScript函数的相互调用

C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
  问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;
  2、在前台写一个js函数,内容为document.getElementById("btn1").click();
  3、在前台或后台调用js函数,激发click事件,等于访问后台c#函数;
方法二:1、函数声明为public  
  后台代码(把public改成protected也可以)
  public string ss()
  {
  return("a");
  }
  2、在html里用可以调用
  前台脚本
  < language=javascript>
  var a = "";
  alert(a);
 
方法三:1、< language="javascript">
 
 
 
方法四:< language="javascript">
function SubmitKeyClick() ......
总记录数:642; 总页数:107; 每页6 条; 首页 上一页 [4] [5] [6] [7] 8 [9] [10] [11] [12] [13]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号