惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
V
Visual Studio Blog
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
L
LangChain Blog
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
P
Proofpoint News Feed
博客园_首页
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 海蓝心

业余时间折腾了个微信小程序版本的街机游戏模拟器(吾爱街机),8090后的童年回忆,欢迎大家体验 Flex Formatter (flex ide 代码格式工具) 安装Android 开发工具 (二) Android 是什么 (一) 个性化印品DIY制作软件《光影21度》(.net客户端与flex通信技术) flash 电子相册 功能强大 在线传输软件 支持断点续传 flex版 个性化数码印刷在线diy 学习XSLT的知识积累 XMLHttpRequest介绍 委托学习笔记二(多播委托) 委托学习笔记一(调用委托) 委托和事件— 一个虚构的故事 ASP.NET程序中常用的三十三种代码(5) ASP.NET程序中常用的三十三种代码(6) ASP.NET程序中常用的三十三种代码(3) ASP.NET程序中常用的三十三种代码(4) ASP.NET程序中常用的三十三种代码(2) C#有关基础知识汇集
ASP.NET程序中常用的三十三种代码(1)
海蓝心 · 2005-11-18 · via 博客园 - 海蓝心

 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(’../ShippedGrid.aspx?id=" + OrderItemID + "’)");
  }
  
    ★特别注意:【?id=】 处不能为 【?id =】

posted on 2005-11-18 10:40  海蓝心  阅读(238)  评论()    收藏  举报