asp.net常用語句收集(轉)

1.//彈出對話框.點擊轉向指定頁面
Response.Write("<script>window.alert('該會員沒有提交申請,請重新提交!')</script>");
Response.Write("<script>window.location ='http://www.cgy.cn/bizpulic/upmeb.aspx'</script>");

2.//彈出對話框
Response.Write("<script language='javascript'>alert('產品添加成功!')</script >");

3.//刪除文件
string filename ="20059595157517.jpg";
pub.util.DeleteFile(HttpContext.Current.Server.MapPath("../file/")+filename);

4.//邦定下拉列表框datalist
System.Data.DataView dv=conn.Exec_ex("select -1 as code,'請選擇經營模式' as content from dealin union select code,content from dealin");
this.dealincode.DataSource=dv;
this.dealincode.DataTextField="content";
this.dealincode.DataValueField="code";               
this.dealincode.DataBind();
this.dealincode.Items.FindByValue(dv[0]["dealincode"].ToString()).Selected=true;

5.//時間去秒顯示
<%#  System.DateTime.Parse(DataBinder.Eval(Container.DataItem,"begtime").ToString()).ToShortDateString()%>

6.//標題帶鏈接
<%# "<a class=/"12c/" target=/"_blank/" href=/"http://www.cgy.cn/product/product_html/pr_"+DataBinder.Eval(Container.DataItem,"procode")+".html/">"+ DataBinder.Eval(Container.DataItem,"proname")+"</a>"%>

7.//修改轉向
<%# "<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>"%>

9.//輸出數據格式化  "{0:F2}" 是格式 F2表示小數點後剩兩位
<%# DataBinder.Eval(Container, "DataItem.PriceMoney","{0:F2}") %>

10.//提取動態網頁內容
Uri uri = new Uri("http://www.apsky.cn");
            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());

11.//獲取" . "後面的字符
i.ToString().Trim().Substring(i.ToString().Trim().LastIndexOf(".")+1).ToLower().Trim()
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章