首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > .NET > C#.NET > .NET中的部份小技巧
【标  题】:.NET中的部份小技巧
【关键字】:.NET
【来  源】:http://blog.csdn.net/txa427/archive/2007/04/12/1562410.aspx

.NET中的部份小技巧

以下全为服务器向前台发的script语句

/*----关闭当前窗口并出现提示对话框----*/
         Response.Write("<script>window.close();</script>");

/*----关闭当前窗口不出现提示对话框----*/
  Response.Write("<script>window.opener=null;");
  Response.Write("window.close();</script>");

/*----延时三秒关闭窗口----*/
  Response.Write("<script>setTimeout('window.opener=null;window.close()',3000);</script>");

/*----全屏显示*.aspx窗口----*/
  Response.Write("<script>window.open('*.aspx','url','fullScreen');</script>");

/*----全屏显示本窗口----*/
  Response.Write("<script>window.open(location,'url','fullScreen');</script>");

/*----打开另存为对话框----*/
  Response.Write("<script>document.execCommand('saveAs');</script>");

/*----打开打开对话框----*/
  Response.Write("<script>document.execCommand('open');</script>");

/*----打开打印对话框----*/
  Response.Write("<script>document.execCommand('print');</script>");

/*----全屏打开一个窗体----*/
window.open('web/study/index.htm','','fullscreen=1,menubar=no,toolbar =no, resizable=no, location=no, status=no');
window.opener=null;window.close();


/*----在单击按钮Button1时在前台出现一个Y/N的对话框,按Y执行Button1的Button1_Click事件,N时不执行----/*
Button1.Attributes.Add("onclick","javascript:return confirm('are you ok ');");

 

/*----单击按钮后在事件处理中按条件是否激发,将脚本发至前台执行,提示窗口与窗体同步----*/
Page.RegisterStartupScript("key","<script>window.alert('提示 Button1_Click  事件');</script>");

 

//在框架中的菜单处怎么样调用一个新界面在另外一个框架中显示
Page.RegisterStartupScript("","<script>top.frames('main').location='"+e.Item.ToolTip.ToString()+"';</script>");

 

//关闭框架,并重新定位到一个指定的页面
Response.Write("<script >top.location.href = 'login.aspx';</script>");
1:Page.RegisterStartupScript("","<script >top.location.href = 'login.aspx';</script>;");

2:Page.RegisterStartupScript("","<script >top.opener=null;window.open('../../index.aspx');top.close();</script>;");
     
   
    
  

 


   
 
 
 window.external.addFavorite(location,"牛耳软件教育");


 window.external.showBrowserUI("organizeFavorites",null);


 window.external.showBrowserUI("privacySettings",null);

 location.replace("view-source:"+location);


 location.reload();


 history.go(0);

 history.forward();

 history.go(1);

 history.back();

 history.go(-1);

asp.net 中的分页SQL语句(每页显示6行,)
select *  from (select top n  * from titles order by title_id ) a where
title_id  not in (select  top n-6 title_id from titles  order by title_id)

 

连接Access数据库
dbname=server.mappath("authors.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )

邦定数据字段表达式
DataBinder.Eval(Container.DataItem,"字段名","格式")   ------格式一般为{0:xxx}


安装协议的制作
用WORD软件输入协议内容,然后保存为*.rtf格式就可


密码加密法(须引入System.Web.Security)
FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text,"SHA1/MD5")

 

 

为DataList 加入主键
DataList1.DataKeyField="ChampionID";   为DataList1加入主键字段ChampionID
int Id=(int)DataList1.DataKeys[e.Item.ItemIndex];  取得选择行的主键值


返回指定路径中的文件扩展名(返回为.doc如是word文件)
System.IO.Path.GetExtension(stringpath)


让屏幕滚动到指定位置的脚本
<script>window.scrollTo(0,10000);</script>
   
表中套表中
内表中的数据源获取

((System.Data.DataRowView)Container.DataItem).CreateChildView("ood")   
//ood为关系
DataRelation dr=new DataRelation("ood",ds.Tables["o"].Columns["orderid"],ds.Tables["oo"].Columns["orderid"]);
ds.Relations.Add(dr);
   
为DataGrid自动编号
ItemDataBound()
{
 if(e.Item.ItemIndex!=-1)
 {
  int orderID=e.Item.ItemIndex+1;
  e.Item.Cells[0].Text=orderID.ToString();
 }
}  
   

页面回传时保持界面的滚动条位置不变 
page.smartNavigation=true

 

向IIS注册
aspnet_regiis /i

 


返回为任何会话和任何作用域中的指定表最后生成的标识值。
select IDENT_CURRENT('txa')

 

 

 


获得选中行的第一列的值
this.UltraWebGrid1.DisplayLayout.SelectedRows[0].Cells[0].Text;

判断是否有选中的行
this.UWDataGrid.DisplayLayout.SelectedRows.Count==0

 

 

返回跨两个指定日期的日期和时间边界数。

语法
DATEDIFF ( datepart , startdate , enddate )
startdate 是从 enddate 减去。如果 startdate 比 enddate 晚,返回负值。


网页在线QQ的代码    详细请见http://is.qq.com/webpresence/code.shtml
<a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=224225439&Site=wpa.qq.com&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:224225439:6 alt="点击这里给我发消息"></a>


取得页面访问的来源
Uri MyUrl = Request.UrlReferrer;
Response.Write(MyUrl.Host);

 

打印本页
<A href="javascript:window.print()">打印本页</A>  

验证码的生成:【上一篇】
获取CPU的序列号:【下一篇】
【相关文章】
  • C#中(.net1.1)公元历转农历的算法
  • Asp.net 2.0 自定义控件开发[实现自动计算功能(AutoComputeControl)][示例代码下载]
  • CrystalReport与ASP.net的集成
  • ASP.NET AJAX Client Library: 更繁?更简?
  • ASP.Net随想_服务器控件的页面请求模型
  • [你必须知道的.NET] 第二回:对抽象编程:接口和抽象类
  • 《ASP.NET AJAX程序设计 第I卷》的心路历程
  • ASP.NET AJAX文档更新,相关录像和一些酷文章
  • 本星期二我将给佛罗里达的太空海岸 .NET 用户组织做讲座
  • ASP.NET Connections大会上我做的讲座的讲义: WPF/E,LINQ和ASP.NET技巧/诀窍
  • 【随机文章】
  • 《A3》浅谈受人冷落的剑战士
  • CuteFTP实用技巧
  • 一步一步学习代理服务器
  • 蠕虫病毒“恶鹰变种”分析报告(1)
  • NETSCAPE浏览技巧拾零
  • 不论是Windows默认开机画面
  • Proxool连接池的简单配置
  • C的符号扩展(字符强制转换成较大整数是碰到的问题)
  • 计算机编程语言族图
  • 找到一个linux下的快速开发工具SlickEdit
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.