1.//弹出对话框。点击转向指定页面
Response.Write(" <script>window.alert('该会员没有提交申请,请重新提交!') </script>"); ='http://www.51aspx.com/bizpulic/upmeb.aspx' </script>"); |
Response.Write(" <script language='javascript'>alert('产品添加成功!') </script >"); |
string filename ="20059595157517.jpg"; +filename); |
System.Data.DataView dv=conn.Exec_ex("select -1 as code,'请选择经营模式' as content from dealin union select code,content from dealin"); ()).Selected=true; |
<%# System.DateTime.Parse(DataBinder.Eval (Container.DataItem,"begtime").ToString()).ToShortDateString()%> |
<%# " <a class=/"12c/" target=/"_blank/" href=/"http://www.51aspx/CV/_"+DataBinder.Eval (Container.DataItem,"procode")+".html/">"+ DataBinder.Eval(Container.DataItem,"proname")+" </a>"%> |
<%# " <A href=/"editpushpro.aspx?id="+DataBinder.Eval (Container.DataItem,"code")+"/">"+"修改 "+" </A>"%> |
8.//弹出确定按钮
<%# " <A id=/"btnDelete/" οnclick=/"return confirm('你是否 确定删除这条记录吗?');/" href=/"pushproduct.aspx? dl="+DataBinder.Eval(Container.DataItem,"code") +"/">"+"删除"+" </A>"%> |
<%# DataBinder.Eval(Container, "DataItem.PriceMoney","{0:F2} ") %> |
Uri uri = new Uri("http://www.51aspx.com/"); WebRequest req = WebRequest.Create(uri); WebResponse resp = req.GetResponse(); Stream str = resp.GetResponseStream(); StreamReader sr = new StreamReader(str,System.Text.Encoding.Default); string t = sr.ReadToEnd(); this.Response.Write(t.ToString()); |
i.ToString().Trim().Substring(i.ToString().Trim().LastIndexOf(".") +1).ToLower().Trim() |
12. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx? id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)< /script>") |
接收参数:
string a = Request.QueryString("id"); string b = Request.QueryString("id1"); |
Button1.Attributes.Add("onclick","return confirm(’确认?’) "); ’)){return true;}else{return false;}") |
13.删除表格选定记录
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex]; intEmpID.ToString() |
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e) 您是否确定要删除这条信息’);"); |
private void grdCustomer_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) ListItemType.AlternatingItem) Default.aspx?id=" + e.Item.Cells[0].Text + "’);");
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) "location.href=’../ShippedGrid.aspx?id=" + orderItemID + "’ "); 双击表格打开新一页 if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) (’../ShippedGrid.aspx?id=" + orderItemID + "’)"); |
16.表格超连接列传递参数
<asp:HyperLinkColumn Target="_blank" headertext="ID号" DataTextField="id" NavigateUrl="aaa.aspx?id=’ name=’<%# DataBinder.Eval(Container.DataItem, "数据字段2")%>’ / > |
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem) ("onclick","this.style.backgroundColor=’#99cc00’; 写在DataGrid的_ItemDataBound里
ListItemType.AlternatingItem) ("onmouseover","this.style.backgroundColor=’#99cc00’; ’’;this.style.color=’’;"); |
18.关于日期格式
日期格式设定
DataFormatString="{0:yyyy-MM-dd}" 列"].text.ToString("yyyy-MM-dd")) |
19.获取错误信息并到指定页面
不要使用Response.Redirect,而应该使用Server.Transfer // in global.asax //其余的非HttpUnhandledException异常交给ASP.NET自己处理就okay了 :) 务器端执行,这样就可以在错误处理页面得到出错信息并进行相应的处理 |
Cookie.Expires=[DateTime]; Response.Cookies("UserName").Expires = 0 |