ASP.NET简单应用

王朝asp·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

连接数据库

<appSettings>

<add key="sqllink" value="server=yfq-001;uid=ADM;pwd=sdadm;database=DBMT50"></add>

<add key="sqllink1" value="server=ymc;uid=sa;pwd=;database=Northwind"></add>

</appSettings>

打开连接

string connstr=System.Configuration.ConfigurationSettings.AppSettings["sqllink"];

SqlConnection conn=new SqlConnection(connstr);

conn.Open();

添加DataGrid

SqlDataAdapter dr=new SqlDataAdapter(sqlstr,conn);

DataSet ds=new DataSet();

dr.Fill(ds,"usract");

if(Convert.ToInt32(ds.Tables["ContList"].Rows.Count.ToString())==0)

{

this.DataGrid1.ShowFooter=true;

}

this.DataGrid1.DataSource=ds.Tables["usract"].DefaultView;

this.DataGrid1.DataBind();

ADO.NET应用

string sql="select count(*) as icount from sysoper where logname='"+this.usrname.Text+"'";

SqlCommand comm=new SqlCommand(sql,conn);

SqlDataReader dr1=comm.ExecuteReader();

dr1.Read();

string count=dr1["icount"].ToString();

dr1.Close();

panel显示条

<asp:Panel id="Panel1" style="Z-INDEX: 101; LEFT: 64px; OVERFLOW: scroll;

POSITION: absolute; TOP: 288px" runat="server" Height="192px" Width="568px">

DIV滚动条

<DIV id="SelectShow1" style="OVERFLOW-Y: auto; OVERFLOW-X: auto;

WIDTH: 83.08%; HEIGHT: 104px">

<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>

</DIV>

enconding加密

System.Web.HttpUtility.UrlEncode(this.txtgrpid.Text.Trim())

System.Web.HttpUtility.HtmlDecode(Request.QueryString["grpid"])

vs.net2003和vs.net2005 b2的使用

用2003

c:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i

c:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -r

用2005

c:\WINNT\Microsoft.NET\Framework\v2.0.50215\aspnet_regiis.exe -i

c:\WINNT\Microsoft.NET\Framework\v2.0.50215\aspnet_regiis.exe -r

IIS注册

C:\>\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis -i

开始安装 ASP.NET (1.1.4322.0)。

已安装完 ASP.NET (1.1.4322.0)。

regsvr32 C:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll

webform调用windowsfrom

if (MessageBox.Show("确定要删除?", "提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1,

MessageBoxOptions.ServiceNotification )==DialogResult.OK)

{//do some useful things }

//调用using System.Windows.Forms;这个包

表格强行换行

<table style="word-break:break-all">

表格中的字符全是数字,或者字母,或者数字和字母,默认是不换行的.上面的是换行的

动态生成DataGrid

BoundColumn column1=new BoundColumn();

column1.HeaderText="登陆名称";

column1.DataField="UsrName";

column1.HeaderStyle.Wrap=false;

column1.ItemStyle.Wrap=false;

//column1.Visible=true;

column1.HeaderStyle.HorizontalAlign=HorizontalAlign.Center;

this.DataGrid1.Columns.Add(column1);

HyperLinkColumn linkcolumn1=new HyperLinkColumn();

linkcolumn1.DataNavigateUrlField="actid";

linkcolumn1.HeaderText="修改";

linkcolumn1.Text="开始修改";

//linkcolumn1.DataNavigateUrlFormatString="edit_usr.aspx?actid='+e.Item.Cells[0].Text+'&grpid='+e.Item.Cells[4].Text+'&pnltype='++System.Web.HttpUtility.

UrlEncode(e.Item.Cell[3].Text)++'";//this.Response.Write("window.location.href='edit_usr.aspx?actid="+this.txtactid.Text.Trim()+"&grpid="+this.txtgrpid.Text.Trim()+"&pnltype="+System.Web.HttpUtility.

UrlEncode(this.actidgrpid.Text.Trim())+"'");

//linkcolumn1.DataNavigateUrlFormatString="edit_usr.aspx?actid={0}&grpid={4}";

//只能传一个值是键

linkcolumn1.HeaderStyle.Wrap=false;

linkcolumn1.ItemStyle.Wrap=false;

linkcolumn1.Visible=true;

linkcolumn1.HeaderStyle.HorizontalAlign=HorizontalAlign.Center;

linkcolumn1.ItemStyle.HorizontalAlign=HorizontalAlign.Center;

this.DataGrid1.Columns.Add(linkcolumn1);

时间格式

d 月中的某一天。一位数的日期没有前导零。

dd 月中的某一天。一位数的日期有一个前导零。

ddd 周中某天的缩写名称,在 AbbreviatedDayNames 中定义。

dddd 周中某天的完整名称,在 DayNames 中定义。

M 月份数字。一位数的月份没有前导零。

MM 月份数字。一位数的月份有一个前导零。

MMM 月份的缩写名称,在 AbbreviatedMonthNames 中定义。

MMMM 月份的完整名称,在 MonthNames 中定义。

y 不包含纪元的年份。如果不包含纪元的年份小于 10,则显示不具有前导零的年份。

yy 不包含纪元的年份。如果不包含纪元的年份小于 10,则显示具有前导零的年份。

yyyy 包括纪元的四位数的年份。

gg 时期或纪元。如果要设置格式的日期不具有关联的时期或纪元字符串,则忽略该模式。

h 12 小时制的小时。一位数的小时数没有前导零。

hh 12 小时制的小时。一位数的小时数有前导零。

H 24 小时制的小时。一位数的小时数没有前导零。

HH 24 小时制的小时。一位数的小时数有前导零。

m 分钟。一位数的分钟数没有前导零。

mm 分钟。一位数的分钟数有一个前导零。

s 秒。一位数的秒数没有前导零。

ss 秒。一位数的秒数有一个前导零

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航