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

推荐订阅源

WordPress大学
WordPress大学
A
About on SuperTechFans
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
博客园 - 聂微东
博客园 - Franky
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
量子位
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - 海蓝心

业余时间折腾了个微信小程序版本的街机游戏模拟器(吾爱街机),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)  评论()    收藏  举报