国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
一天精通asp.net:專(zhuān)為有其他語(yǔ)言基礎(chǔ)的人 (轉(zhuǎn))

1、Validator
2、IsPostBack
3、AutoPostBack??丶x開(kāi)焦點(diǎn)的時(shí)候自動(dòng)Post。
4、repeater控件的使用。:Repeater控件比以前版本的asp.net好用了,只要 Eval就可以了,不用DataBinder.Eval(container.DataItem,"***"):了,只要Eval("Name")就可以,注意不能丟了前面的“#”。
    <asp:Repeater ID="Repeater1" runat="server">
        <HeaderTemplate>
            嘎嘎嘎
        </HeaderTemplate>
        <ItemTemplate>
        <%# Eval("Name")%>
        <%# Eval("Desc")%>
        </ItemTemplate>
    </asp:Repeater>

        protected void Button3_Click(object sender, EventArgs e)
        {
            List<Person> list = new List<Person>();
            list.Add(new Person(){Name="芭芭拉",Desc="白牙唄"});
            list.Add(new Person(){Name="奧巴馬",Desc="黑黝黑"});
            Repeater1.DataSource = list;
            Repeater1.DataBind();
        }
5、DataList控件:
(1)行的高亮選中
     <asp:DataList ID="DataList1" runat="server" >
        <SelectedItemStyle BackColor="#FF6666" />
    <ItemTemplate>
        <%# Eval("Name")%>
        <%# Eval("Desc")%>    
        <asp:LinkButton ID="LinkButton1" runat="server" Text="選擇" CommandName="select" />  
    </ItemTemplate>
    </asp:DataList>
核心是CommandName這個(gè)屬性,可選值還有edit、delete等可選值,當(dāng)按鈕被點(diǎn)擊的時(shí)候?qū)?huì)執(zhí)行EditCommand、DeleteCommand等事件。
(2)行的在位編輯:
    <asp:DataList ID="DataList1" runat="server"
        oneditcommand="DataList1_EditCommand">
        <SelectedItemStyle BackColor="#FF6666" />
    <EditItemTemplate>
        <asp:TextBox runat="server" ID="t1" Text='<%# Eval("Name")%>' />
        <asp:TextBox runat="server" ID="t2" Text='<%# Eval("Desc")%>' />
        <asp:Button runat="server" Text="提交" CommandName="update" />
    </EditItemTemplate>
    <ItemTemplate>
        <%# Eval("Name")%>
        <%# Eval("Desc")%>    
        <asp:LinkButton ID="LinkButton1" runat="server" Text="編輯" CommandName="edit" />  
    </ItemTemplate>
    </asp:DataList>

        protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
        {
            DataList1.EditItemIndex = e.Item.ItemIndex;
            ReBind();
        }

        private void ReBind()
        {
            List<Person> list = new List<Person>();
            list.Add(new Person() { Name = "芭芭拉", Desc = "白牙唄" });
            list.Add(new Person() { Name = "奧巴馬", Desc = "黑黝黑" });
            Repeater1.DataSource = list;
            Repeater1.DataBind();

            DataList1.DataSource = list;
            DataList1.DataBind();
        }
(3)行的在位編輯并且提交修改
    <asp:DataList ID="DataList1" runat="server"
        oneditcommand="DataList1_EditCommand"
        onupdatecommand="DataList1_UpdateCommand">
        <SelectedItemStyle BackColor="#FF6666" />
    <EditItemTemplate>
        <asp:TextBox runat="server" ID="t1" Text='<%# Eval("Name")%>' />
        <asp:TextBox runat="server" ID="t2" Text='<%# Eval("Desc")%>' />
        <asp:Button runat="server" Text="提交" CommandName="update" />
    </EditItemTemplate>
    <ItemTemplate>
        <%# Eval("Name")%>
        <%# Eval("Desc")%>    
        <asp:LinkButton ID="LinkButton1" runat="server" Text="編輯" CommandName="edit" />  
    </ItemTemplate>
    </asp:DataList>
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["PersonList"] == null)
            {
                List<Person> list = new List<Person>();
                list.Add(new Person() { Name = "芭芭拉", Desc = "白牙唄" });
                list.Add(new Person() { Name = "奧巴馬", Desc = "黑黝黑" });
                Repeater1.DataSource = list;
                Repeater1.DataBind();
                Session["PersonList"] = list;
            }           
        }

        protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
        {
            DataList1.EditItemIndex = e.Item.ItemIndex;
            ReBind();
        }

        private void ReBind()
        {
            DataList1.DataSource = Session["PersonList"];
            DataList1.DataBind();           
        }

        protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
        {
            TextBox nT1 = e.Item.FindControl("t1") as TextBox;
            TextBox nT2 = e.Item.FindControl("t2") as TextBox;
            //不要直接從DataList1.DataSource中取,因?yàn)槿〉降氖莕ull
            List<Person> list = Session["PersonList"] as List<Person>;
            Person curPerson = list[DataList1.EditItemIndex];
            curPerson.Name = nT1.Text;
            curPerson.Desc = nT2.Text;
            DataList1.EditItemIndex = -1;
            ReBind();
        }
    }
6 GridView控件
    <asp:GridView ID="GridView1" runat="server" AllowSorting="True"
        AutoGenerateColumns="False" onrowcommand="GridView1_RowCommand"
        onsorting="GridView1_Sorting">
        <Columns>
            <asp:ButtonField ButtonType="Button" CommandName="DingGou" HeaderText="訂購(gòu)"
                ShowHeader="True" Text="訂購(gòu)" />
            <asp:ButtonField ButtonType="Button" CommandName="TuiDing" HeaderText="退訂"
                ShowHeader="True" Text="退訂" />
            <asp:BoundField DataField="Name" HeaderText="名稱(chēng)" SortExpression="Name" />
            <asp:BoundField DataField="Desc" HeaderText="描述" SortExpression="Desc" />
        </Columns>
    </asp:GridView>

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DingGou")
            {
                Debug.WriteLine("第"+e.CommandArgument+"行被訂購(gòu)");
            }
        }

        protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
        {

        }
7、用戶(hù)控件(UserControl)
通過(guò)向?qū)?chuàng)建一個(gè)UserControl,然后就可以任意編輯這個(gè)UserControl,而且還可以為UserControl增加屬性、事件。使用的時(shí)候只要將控件直接從SolutionExplorer拖到頁(yè)面上就可以。
8、繼承控件
(1)通過(guò)向?qū)?chuàng)建一個(gè)WebCustomControl。
(2)定義自己應(yīng)用界面。需要重載從Control類(lèi)繼承來(lái)的CreateChildControls方法,并在其中生成界面控件。如果用戶(hù)定義的控件會(huì)在一個(gè)頁(yè)面中反復(fù)使用,最好implements System.Web.UI.INamingContainer,它會(huì)為該控件創(chuàng)建一個(gè)唯一的命名空間。
(3)定義自己控件的消息處理函數(shù)。自己定義的控件含有兩種類(lèi)型的消息,一是包含的子控件所產(chǎn)生的消息,二是自定義的控件消息。
9、向工程中添加“Global Application Class”就可以添加Global.asax,在這里可以監(jiān)聽(tīng)Application、Session的生命周期。
10、(1)Response.Redirect("newpage.aspx");客戶(hù)端轉(zhuǎn)發(fā)
(2)Server.Transfer("newpage.aspx");服務(wù)器端轉(zhuǎn)發(fā)
11、web.config配置
(1)  <appSettings>
    <add key="FTP" value="127.0.0.1"/>
  </appSettings>
  this.Title = WebConfigurationManager.AppSettings["FTP"];
(2)
  <connectionStrings>
    <add name="mydb"  connectionString="jdbc:ddd"/>
  </connectionStrings>
  this.Title = WebConfigurationManager.ConnectionStrings["mydb"].ConnectionString;
12、BulletedList就是<ul><ol>
13、PostBack本質(zhì)論
ASP.NET also adds two additional hidden input fields that are used to pass information
back to the server. This information consists of the ID of the control that raised the event and
any additional information that might be relevant. These fields are initially empty, as shown
here:
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
The __doPostBack() function has the responsibility for setting these values with the
appropriate information about the event and then submitting the form. A slightly simplified
version of the __doPostBack() function is shown here:
<script language="text/javascript">
function __doPostBack(eventTarget, eventArgument) {
var theform = document.Form1;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
</script>
14、跨頁(yè)表單提交
在頁(yè)1中指定按鈕的PostBackUrl屬性為WebForm1.aspx,這樣表單就會(huì)提交到WebForm1.aspx了,然后在WebForm1.aspx中還可以取到前一頁(yè)中所有的值:
TextBox1.Text = PreviousPage.Title;
還可以將PreviousPage cast成更詳細(xì)的頁(yè)面子類(lèi)。
15、取QueryString的方法:
Request.QueryString["recordID"]
16、Server.UrlEncode(lstItems.SelectedItem.Text)
17、Multiview控件用來(lái)實(shí)現(xiàn)動(dòng)態(tài)界面,Multiview里嵌套多個(gè)view控件,每個(gè)view控件里可以方式其他控件。通過(guò)控制Multiview控件的ActiveViewIndex屬性來(lái)控制不同View的顯示。
18、Wizard控件比Multiview控件更方面,更像一個(gè)TabControl
19、動(dòng)態(tài)圖片:
在pageload的事件中:
Bitmap image = new Bitmap(300, 50);
Graphics g = Graphics.FromImage(image);
Response.ContentType = "image/png";
image.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Gif);
20 頁(yè)面導(dǎo)航
創(chuàng)建SiteMap文件,修改SiteMap文件增加節(jié)點(diǎn)。
在頁(yè)面上增加一個(gè)SiteMapDataSource,然后只要拖TreeView、Menu、SiteMapPath等控件上來(lái),指定DataSource屬性為SiteMapDataSource就可以了。
21 單值綁定
URL = "Images/picture.jpg";
this.DataBind();
<asp:CheckBox id="chkDynamic" Text="<%# URL %>" runat="server" />
22 下拉列表框綁定
    <asp:DropDownList ID="DropDownList1" runat="server" DataTextField="value"
        DataValueField="key">
    </asp:DropDownList>
    IDictionary<string, string> dict = new Dictionary<string, string>();
    dict["1"] = "aa";
    dict["2"] = "bb";
    DropDownList1.DataSource = dict;
    DropDownList1.DataBind();   
23 設(shè)定起始頁(yè):在aspx上點(diǎn)右鍵,選擇“Set as startpage”
24 程序中數(shù)據(jù)庫(kù)連接字符串的設(shè)置
(1)、web.config中加入: 
<connectionStrings>
    <add name="DBConnectionString" connectionString="server=192.168.88.128\SQLEXPRESS1;uid=sa;pwd=123456;database=CRM" providerName="System.Data.SqlClient"/>
  </connectionStrings>
(2)、在IDE中拖放DataSource組件以后,在屬性視圖的ConnectionString屬性中選擇DBConnectionString即可。
(3)、程序中讀取這個(gè)連接字符串的方法:
            System.Configuration.Configuration rootWebConfig =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
            string connString =
                rootWebConfig.ConnectionStrings.ConnectionStrings["DBConnectionString"].ConnectionString;
24 制作簡(jiǎn)單的CRUD頁(yè)面的步驟:
(1)拖放一個(gè)SqlDataSource組件上來(lái),設(shè)定好ConnectionString,命名組件為dsList。
(2)修改SqlDataSource組件的DeleteQuery屬性為:delete from T_PSI_User where FId=@FId
InsertQuery屬性為:INSERT INTO T_PSI_User(FId, FUserName, FPassword) VALUES (NEWID(),@FUserName,@FPassword)
SelectQuery為:select * from T_PSI_User
UpdateQuery為:Update T_PSI_User set FUserName=@FUserName,FPassword=@FPassword where FId=@FId
(3)拖放一個(gè)GridView組件上來(lái),設(shè)定其DataSourceID屬性為dsList。修改AllowPaging、AllowSorting、AutoGenerateDeleteButton、AutoGenerateEditButton屬性為T(mén)rue。設(shè)定AutoGeneratedColumns屬性為false。設(shè)定DataKeyNames屬性為FId(這樣哪怕隱藏了FId字段,Edit、delete功能也能正常執(zhí)行了)
(4)修改GridView的Columns屬性,在彈出的對(duì)話框中點(diǎn)擊【RefreshSchema】鏈接,這樣在BoundField下就顯示了FId、FName、FPassword三個(gè)字段,將FUserName和FPassword字段Add進(jìn)來(lái)。
這樣不用一行代碼,有刪、改功能的頁(yè)面就做好了。下面來(lái)做“增”的功能。
(5)選擇GridView組件,在智能提示中選擇EditTemplete、然后選擇“EmptyTemplete”,拖放一個(gè)FormView組件到EmptyTemplete中,選中Formview組件,在智能提示中設(shè)定DataSource為dsList。
(6)新建一個(gè)【新增】按鈕,編輯其Click事件代碼為:
            GridView1.DataSourceID = "";
            GridView1.DataBind();
(7)設(shè)定FormView的ItemInserted事件代碼為:
RefreshList();
RefreshList()函數(shù)定義如下:
            GridView1.DataSourceID = "dsList";
            GridView1.DataBind();
這樣“增”的功能就做好了,不過(guò)還是有缺憾,那就是顯示出了不歸我們管的FId字段,并且字段名、按鈕都是英文的。
(8)選中,F(xiàn)ormView組件,然后點(diǎn)擊EditTemplete,選中InsertTemplete,這樣就可以刪除不需要的FId字段了,并且可以修改控件布局以及界面的語(yǔ)言文字。
(9)這樣的話Insert界面中的“Cancel取消”按鈕還是不能用,編輯FormView1的ItemCommand事件,編寫(xiě)如下的代碼:
            if (e.CommandName == "Cancel")
            {
                RefreshList();
            }
25 上面實(shí)現(xiàn)CRUD的方法有兩個(gè)缺陷:
(1)需要編寫(xiě)一個(gè)EmptyTemplete
(2)很難對(duì)Edit的控件做定制
因此我們還是用ListUI和EditUI分置的方法來(lái)解決。步驟:
制作ListUI:
(1)使用datasource、GridView,不過(guò)DataSource只要配置SelectQuery、DeleteQuery即可。
(2)GridView不自動(dòng)生成Edit按鈕。
(3)GridView生成一個(gè)ButtonField,標(biāo)題為“編輯”,CommandName="EditInPage"
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditInPage")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                Guid guid = (Guid)GridView1.DataKeys[index].Value;
                Server.Transfer("/Sys/SysUserEdit.aspx?Action=Edit&FId="+guid);
            }           
        }
(4)新增按鈕的Onclick事件:
Server.Transfer("/Sys/SysUserEdit.aspx?Action=Insert");

制作EditUI:
(1)拖一個(gè)DataSouce控件,按常規(guī)配置InsertCommand和UpdateCommand,配置SelectCommand為“SELECT * FROM [T_PSI_User] where 1<>1”,配置UpdateCommand為“”
(2)拖一個(gè)FormView上來(lái),并且修改EditTemplete和InsertTemplte(可以直接將EditTemplete修改后的拷貝到InsertTemplte,注意不要忘了修改Button的CommandName)
(3)代碼;
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (Request["Action"])
            {
                case "Edit":
                    dsEdit.SelectCommand = "select * from T_PSI_User where FId=@FId";
                    dsEdit.SelectParameters.Clear();
                    dsEdit.SelectParameters.Add("FId", Request["FId"]);
                    FormView1.ChangeMode(FormViewMode.Edit);
                    break;
                case "Insert":
                    FormView1.ChangeMode(FormViewMode.Insert);
                    break;
            }
        }

        protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
        {
            GogoList();
        }       

        protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
        {
            GogoList();
        }

        private void GogoList()
        {
            Server.Transfer("/Sys/SysUserList.aspx");
        }
    }
    }
26、DropDownList實(shí)現(xiàn)基礎(chǔ)資料選擇器,比如在商品編輯中的選擇計(jì)量單位:
(1)拖一個(gè)針對(duì)T_MeasureUnit表的DataSource,比如名字為dsMeasureUnit。
(2)拖一個(gè)商品的Datasource,比如dsMerchan。
(3)拖一個(gè)FormView上來(lái),并且設(shè)定其DataSource為dsMerchan
(4)將一個(gè)DropDownList放到FormView中,因?yàn)橹挥羞@樣才能設(shè)定DropDownList本身的綁定。
(5)選中DropDownList,在智能提示中選擇“ConfigDateSource”,在這里配置上dsMeasureUnit。
(6)選中DropDownList,在智能提示中選擇“EditDataBindings”,然后設(shè)定綁定到dsMerchan的FMeasureUnitId字段。

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
ASP.NET數(shù)據(jù)綁定
ASP.NET 2.0中實(shí)現(xiàn)模板中的數(shù)據(jù)綁定
DataList嵌套GridView實(shí)現(xiàn)文章分類(lèi)列表顯示
在gridview中把行中多余的字符用省略號(hào)代替(C#)
DataList 嵌套 全選反選
Datalist分頁(yè)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服