国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#Web應用程序入門經典學習筆記之二

2024-09-07 17:05:20
字體:
來源:轉載
供稿:網友
讀取Web.config中設置

   Conn = new SqlConnection(ConfigurationSettings.AppSettings[“cnFriends.ConnectString”]);

 

  <appSettings>

    <!--   User application and configured property settings go here.-->

    <!--   Example: <add key="settingName" value="settingValue"/> -->

<add key="cnFriends.ConnectionString" value="data source=(local)/NetSdk;initial catalog=FriendsData;user id=sa" />  </appSettings>

 


幾個命名空間

當用到DataSet時,用using system.Data.SqlClient

當配置Web.config時,用using system.Configuration


這個讓我想起了大一學習C語言時

bool visible

btnSearch.Text = visible? “New Search” : “Search” ;


這個也蠻好

dsResult.tables[“Users”].rows.count

Conver.Tonint32(ConfigurationSettings.AppSettings[“Cokuale.number”]);


夠狠1:用Session保存結果并綁定

Session[“Search”] = dsResults;

dsResults = (DataSet) Session[“Search”];

grdResults.DataBind();
其實,Session,Application等存的是object 類型,因此,最后都要顯式轉換類型
順便說說,判斷是否取到字符串類型的值用null 判斷。

夠狠2:從DataTable中選擇行

DataRow[] rows = dsResults.Tables[“Users”].Select(filter);

dsResults = dsResults.Clone();

foreach(DataRow row in rows)

{

         dsResults.Tables[“Tables”].ImportRow(row);

}


獲取webForm 上的一個控件

ImageButton img = (ImageButton)e.Item.FindControl(“Selectbutton”)


跳轉:

Server.Transfer(“Caoxicao.aspx”);


服務器控件添加js腳本(Attributes屬性)

imgShow.Attributes.Add(“onclick”,”document.getElementById(‘tbPrefs').style.display = ‘block';”);
再(Style屬性),

img.Style.Add(“Cursor”,'Pointer');


Color相關:

ColorConvert cv = new ColorConvert();

Color selected = Color.Empty;

Selected = (olor)cv.ConvertFromString(White);


增加Cookie

Response.Cookies.Add(new HttpCookie(“backColor”,r))


我的最愛----用戶控件

Using FriendsReunion.Controls;

Protectd override void Oninit(EventArgs e)

{

         FriendsFooter _footer = (FriendsFooter)LoadControl(Request.ApplicationPath+”/Controls/ FriendsFooter.aspx”);
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 饶阳县| 宜兴市| 田东县| 台江县| 青铜峡市| 枣强县| 平乐县| 繁峙县| 四会市| 梨树县| 钦州市| 平塘县| 深水埗区| 汤原县| 兴海县| 苍山县| 双峰县| 即墨市| 沐川县| 上虞市| 东港市| 福贡县| 桓台县| 小金县| 呼玛县| 邵阳县| 札达县| 肥城市| 黎川县| 玛沁县| 伊宁市| 朝阳市| 德江县| 阳西县| 平塘县| 庆安县| 新密市| 临高县| 潞西市| 察哈| 大兴区|