ASP.NET中常用的三十三种代码
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 myTableCell;
myTableCell = e.Item.Cells[14];
LinkButton myDeleteButton ;
myDeleteButton = (LinkButton)myTableCell.Controls[0];
myDeleteButton.Attributes.Add("onclick","return confirm('您是否确定要删除这条信息');");
break;
default:
break;
}
}
5.点击表格行链接另一页
private void grdCustomer_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//点击表格打开
if (e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
e.Item.Attributes.Add("onclick","window.open('Default.aspx?id=" + e.Item.Cells[0].Text + "');");
}
双击表格连接到另一页
在itemDataBind事件中
if(e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
{
string orderItemID =e.item.cells[1].Text;
...
e.item.Attributes.Add("ondblclick", "location.href='../ShippedGrid.aspx?id=" + orderItemID + "'");
}
双击表格打开新一页
if(e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
{
string orderItemID =e.item.cells[1].Text;
...
e.item.Attributes.Add("ondblclick", "open('../S
相关文档:
1 示例xml文件 model.xml
<?xml version="1.0" encoding="utf-8" ?>
<DrRoot>
<SiteName>xml操作示例</SiteName>
<SiteUrl>www.abc.com.cn</SiteUrl>
.net开源论坛
<SiteKeyWord>xml操作示例</SiteKeyWord>
<FileType>gif|jpg| ......
(1)在WEB页面上加入JS脚本和存放ListBox事件的隐藏输入框,LISTBOX是用来保存时间的名称,在CS页面用到:其JS代码如下:
<script language="javascript">
function ListBox1_DoubleClick() {
/* we will change value of this hidden field so t ......
JavaScript实现:
<mce:script type ="text/javascript" ><!--
function readWord()
{
var div1=document .getElementById ("div1");
var WordApp,WordDoc,Str;
WordApp =new ActiveXObject ("Word.application");
WordDoc =WordApp.Documents.Open("F:\\工作日志.doc");
......
由于项目需要一个论坛,本来有CS的,在.net下很出名的国外开源论坛。但为了适应国内的风气,最后选用在国内如日中天的Discuz!NT。
将Discuz与asp.net开发的网站整合,有很多人已经完成了。
但在网上没有找到较详细的描述。方法倒是有很多种。
在项目中注册新用户时,也同时调用论坛的用户注册,这样就同步注册了。至于删 ......
用asp.net 的回执(postback)是很爽,但若一个长长的页面,一回执后,跳到了页首,体验不爽。 但在asp.net的page页面里面有一个很爽的属性Page.MaintainScrollPositionOnPostBack 属性,设为true即可。 获取或设置一个值,该值指示回发后是否将用户返回到客户端浏览器中的同一位置。 <%@ Page Title="" Lang ......