同桌上课用手指进去了好爽_欧美丰满熟妇xxⅹⅹ性大i_成人av天天日天天拍拍_猛男gay帅男gay男男同志_欧美va天堂在线观看_人妻无码av中文系列三里桃花_亚欧免费无码在线观看_久久久精品国产亚洲av水_日韩在线免费看污污污_2021无码专区人妻系列日韩

首頁(yè) 優(yōu)化推廣 Asp.net非常實(shí)用的51個(gè)代碼(1)

Asp.net非常實(shí)用的51個(gè)代碼(1)

來(lái)源: | 時(shí)間:2013/8/28 14:38:32 |

1.//彈出對(duì)話框.點(diǎn)擊轉(zhuǎn)向指定頁(yè)面

  1. Response.Write(&quot;<script>window.alert('該會(huì)員沒(méi)有提交申請(qǐng),請(qǐng)重新提交!')</script>&quot;);

  2. Response.Write(&quot;<script>window.location ='http://www.51aspx.com/bizpulic/upmeb.aspx'</script>&quot;);
復(fù)制代碼

2.//彈出對(duì)話框

  1. Response.Write(&quot;<script language='javascript'>alert('產(chǎn)品添加成功!')</script >&quot;);
復(fù)制代碼

3.//刪除文件

  1. string filename =&quot;20059595157517.jpg&quot;;

  2. pub.util.DeleteFile(HttpContext.Current.Server.MapPath(&quot;../file/&quot;)+filename);
復(fù)制代碼

4.//綁定下拉列表框datalist

  1. System.Data.DataView dv=conn.Exec_ex(&quot;Select -1 as code,'請(qǐng)選擇經(jīng)營(yíng)模式' as content from dealin union Select code,content from dealin&quot;);

  2. this.dealincode.DataSource=dv;

  3. this.dealincode.DataTextField=&quot;content&quot;;

  4. this.dealincode.DataValueField=&quot;code&quot;;    

  5. this.dealincode.DataBind();

  6. this.dealincode.Items.FindByValue(dv[0][&quot;dealincode&quot;].ToString()).Selected=true;
復(fù)制代碼

5.//時(shí)間去秒顯示

  1. <%# System.DateTime.Parse(DataBinder.Eval(Container.DataItem,&quot;begtime&quot;).ToString()).ToShortDateString()%>
復(fù)制代碼

6.//標(biāo)題帶鏈接

  1. <%# &quot;<a class=\&quot;12c\&quot; target=\&quot;_blank\&quot; href=\&quot;http://www.51aspx/CV/_&quot;+DataBinder.Eval(Container.DataItem,&quot;procode&quot;)+&quot;.html\&quot;>&quot;+ DataBinder.Eval(Container.DataItem,&quot;proname&quot;)+&quot;</a>&quot;%>
復(fù)制代碼

7.//修改轉(zhuǎn)向

  1. <%# &quot;<A href=\&quot;editpushpro.aspx?id=&quot;+DataBinder.Eval(Container.DataItem,&quot;code&quot;)+&quot;\&quot;>&quot;+&quot;修改&quot;+&quot;</A>&quot;%>
復(fù)制代碼

8.//彈出確定按鈕

  1. <%# &quot;<A id=\&quot;btnDelete\&quot; onclick=\&quot;return confirm('你是否確定刪除這條記錄嗎?');\&quot; href=\&quot;pushproduct.aspx?dl=&quot;+DataBinder.Eval(Container.DataItem,&quot;code&quot;)+&quot;\&quot;>&quot;+&quot;刪除&quot;+&quot;</A>&quot;%>
復(fù)制代碼

9.//輸出數(shù)據(jù)格式化 "{0:F2}" 是格式 F2表示小數(shù)點(diǎn)后剩兩位

  1. <%# DataBinder.Eval(Container, &quot;DataItem.PriceMoney&quot;,&quot;{0:F2}&quot;) %>
復(fù)制代碼

10.//提取動(dòng)態(tài)網(wǎng)頁(yè)內(nèi)容

  1. Uri uri = new Uri(&quot;http://www.51aspx.com/&quot;);

  2.    WebRequest req = WebRequest.Create(uri);

  3.    WebResponse resp = req.GetResponse();

  4.    Stream str = resp.GetResponseStream();

  5.    StreamReader sr = new StreamReader(str,System.Text.Encoding.Default);

  6.    string t = sr.ReadToEnd();

  7.    this.Response.Write(t.ToString());
復(fù)制代碼

11.//獲取" . "后面的字符

  1. i.ToString().Trim().Substring(i.ToString().Trim().LastIndexOf(&quot;.&quot;)+1).ToLower().Trim()
復(fù)制代碼

12. 打開(kāi)新的窗口并傳送參數(shù):   傳送參數(shù):

  1. response.write(&quot;<script>window.open(’×.aspx?id=&quot;+this.DropDownList1.SelectIndex+&quot;&amp;id1=&quot;+...+&quot;’)</script>&quot;)
復(fù)制代碼

接收參數(shù):

  1. string a = Request.QueryString(&quot;id&quot;);

  2. string b = Request.QueryString(&quot;id1&quot;);
復(fù)制代碼

12.為按鈕添加對(duì)話框

  1. Button1.Attributes.Add(&quot;onclick&quot;,&quot;return confirm(’確認(rèn)?’)&quot;);

  2. button.attributes.add(&quot;onclick&quot;,&quot;if(confirm(’are you sure...?’)){return true;}else{return false;}&quot;)
復(fù)制代碼

13.刪除表格選定記錄

  1. int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];

  2. string deleteCmd = &quot;Delete from Employee where emp_id = &quot; + intEmpID.ToString()
復(fù)制代碼

14.刪除表格記錄警告

  1. private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)

  2. {

  3.  switch(e.Item.ItemType)

  4.  {

  5.   case ListItemType.Item :

  6.   case ListItemType.AlternatingItem :

  7.   case ListItemType.EditItem:

  8.    TableCell myTableCell;

  9.    myTableCell = e.Item.Cells[14];

  10.    LinkButton myDeleteButton ;

  11.    myDeleteButton = (LinkButton)myTableCell.Controls[0];

  12.    myDeleteButton.Attributes.Add(&quot;onclick&quot;,&quot;return confirm(’您是否確定要?jiǎng)h除這條信息’);&quot;);

  13.    break;

  14.   default:

  15.    break;

  16.  }

  17. }
復(fù)制代碼

15.點(diǎn)擊表格行鏈接另一頁(yè)

  1. private void grdCustomer_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)

  2. {

  3.  //點(diǎn)擊表格打開(kāi)

  4.  if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListIte

服務(wù)熱線

153 8323 9821

功能和特性

價(jià)格和優(yōu)惠

網(wǎng)站和維護(hù)

推廣和優(yōu)化

微信服務(wù)號(hào)