ASP.NET小技巧.txt

一.Response對象的Write方法與JavaScript腳本語言的結合使用.(page_51)

彈出提示對話框.
Response.Write("<script>alert('你好!');</script>");

   2.關閉窗口

Response.Write("<script>window.opener=null;window.close();script>");

二.獲取客戶端IP地址.(page_54)

1. 通過Request的userHosaddress屬性.

texBox1.Text=Request.userHosaddress;

2.通過Request的ServerVariabes屬性

TexBox1.Text=Request.ServerVariabes["REMOTE_ADDR"];

三.獲取當前頁面的路徑

Response.Redirect(Request.CurrentExecutionFilePath);

四.如何解決Response.Redirect方法傳遞漢字丟失或亂碼問題?(page_66)

傳值之前.

String 如何解決Response.Redirect方法傳遞漢字丟失或亂碼問題?");

Response.Redirect("a.aspx?name"+name);

接收時

String name"]);

五.打開新窗口並關閉父窗口.(page_81)

      Response.Write("<script language='javascript'>window.open('NewPage.aspx','','width=335,height=219');window.opener=null;window.close();</script>");

六.打開Outlook.

      把Hyperlink控件的NavigateUrl屬性值設置爲:mailto:[email protected]

七.設爲首頁.

      把Linkbutton按扭的OnClientClick屬性設爲:this.style.behavior='url(#default#homepage)';this.sethomepage('http://www.baidu.com')

八.添加到收藏夾.

      把Button控件的OnClientClick屬性值爲:window.external.addFavorite('http://www.baidu.com','百度')

九.DropDownList的方法(page_95).

1.獲取DropDownList控件的索引號和標題.

int Index=DropDownList.SelectedIndex;

string text=DropDownList.SelectedItem;

2.向DropDownList控件的下拉列表框中添加列表項.

DropDownList.Items.Add(new LIstItem("asp.net","0"));

DropDownList.Items.Add(string);

3.刪除選擇的DropDownList控件的列表項.

ListItem ltem=DropDownList1.Selectedlitem;

DripDownlist1.ltems.Remove(ltem);

4.清除所有DripDownlist控件的列表項.

DripDownlist1.Items.Clear();

5.獲取DripDownlist控件包含的列表項數.

int count=DripDownlist.Items.count;

 

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