« Home « Chủ đề ASP.NET Configuration

Chủ đề : ASP.NET Configuration


Có 60+ tài liệu thuộc chủ đề "ASP.NET Configuration"

ASP.NET 4 Unleased - p 40

tailieu.vn

As an alternative, you can improve the performance of your DataBinding expressions by casting the data items to a particular type like this:. ((System.Data.DataRowView)Container.DataItem)[“Title”] %>. You can use the format string to format values such as dates and currency amounts. FIGURE 8.10 Using databinding expressions.. You can find a list of format specifiers by looking up Formatting Types in the...

ASP.NET 4 Unleased - p 41

tailieu.vn

You can connect to a Local database named MyLocalData.mdf by using the following connection string:. Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|MyLocalData.mdf;. When you connect to the MyLocalData.mdf file, the database is attached automatically to Microsoft SQL Server Express.. The connection string includes an AttachDbFilename parameter. This parameter represents the physical path to a database file ( .mdf file). The keyword |DataDirectory| is used in...

ASP.NET 4 Unleased - p 42

tailieu.vn

<form id=”form1” runat=”server”>. <asp:TextBox. id=”txtConnectionString”. Runat=”Server” />. <asp:Button. id=”btnConvert”. <asp:Label. id=”lblResult”. Runat=”server” />. After opening the page in Listing 9.2, if you enter a connection string that looks like this:. System.Data.OracleClient —Use the ADO.NET provider for Oracle when connecting to an Oracle database.. For example, the page in Listing 9.3 uses the ADO.NET Oracle provider to connect to an Oracle...

asp.net 4 unleased - p 43

tailieu.vn

ptg LISTING 9.9 ShowMovieCount.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <style type=”text/css”>. <title>Show Movie Count</title>. <form id=”form1” runat=”server”>. <asp:GridView id=”grdMovies”. Runat=”server” />. <asp:SqlDataSource id=”srcMovies”. ConnectionString=”<. The SqlDataSource control includes a FilterExpression property that enables you to filter the rows returned by the control. You can define complex Boolean filters that include parameters with this property.. For...

asp.net 4 unleased - p 44

tailieu.vn

ptg 404 CHAPTER 9 Using the SqlDataSource Control. LISTING 9.14 CancelCommand.aspx. Page Language=”C#” %>. Import Namespace=”System.Data.SqlClient” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <script runat=”server”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <style type=”text/css”>. <form id=”form1” runat=”server”>. <asp:Label id=”lblError”. Runat=”server” />. <asp:DetailsView id=”dtlMovie”. <asp:SqlDataSource id=”srcMovies”. ConnectionString=”<. Runat=”server” OnUpdating=”srcMovies_Updating” />. ptg 406 CHAPTER 9 Using the SqlDataSource Control. The page in Listing 9.14 includes a srcMovies_Updating() method....

ASP.NET 4 Unleased - p 45

tailieu.vn

ptg Text=’<. Bind(“Comments”) %>’. Runat=”server” />. <asp:Button id=”btnSubmit”. </asp:FormView>. <asp:GridView. id=”grdGuestBook”. <asp:SqlDataSource id=”srcGuestBook”. ConnectionString=”<. Runat=”server”>. <asp:ControlParameter Name=”IPAddress” ControlID=”__page”. PropertyName=”IPAddress” />. </asp:SqlDataSource>. CookieName —The name of the browser cookie.. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <script runat=”server”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:FormView id=”frmVote”. <asp:Label. id=”lblFavoriteColor”. <asp:RadioButtonList id=”rdlFavoriteColor”. SelectedValue=’<%#Bind(“Color”)%>’. <asp:ListItem Value=”Red” Text=”Red” Selected=”True” />. <asp:ListItem Value=”Blue” Text=”Blue” />. <asp:ListItem...

ASP.NET 4 Unleased - p 46

tailieu.vn

ptg 424 CHAPTER 9 Using the SqlDataSource Control. <asp:DetailsView id=”dtlMovie”. Runat=”server” />. <asp:HyperLink Runat=”server”. NavigateUrl=”~/ShowQueryStringParameterMaster.aspx” />. <asp:SqlDataSource id=”srcMovie”. ConnectionString=”<. Runat=”server”>. <asp:QueryStringParameter Name=”Id”. QueryStringField=”Id” />. </asp:SqlDataSource>. The SqlDataSource control in Listing 9.24 includes a QueryStringParameter . The QueryStringParameter supplies the movie ID in the SqlDataSource control’s SelectCommand. SessionField —The name of the item stored in Session state that the SessionParameter represents.....

ASP.NET 4 Unleased - p 47

tailieu.vn

WebHandler Language=”C#” Class=”DynamicImage” %>. Get the Id of the image to display. In the ProcessRequest() method, an instance of the SqlDataSource control is created.. The SqlDataSource control’s ConnectionString and SelectCommand properties are initial- ized. Finally, the SqlDataSource control’s Select() command is executed, and the results are rendered with the Response.BinaryWrite() method.. You need to cast the return value to either...

asp.net 4 unleased - p 48

tailieu.vn

LISTING 10.3 ProgrammaticDataBinding.aspx. Page Language=”C#” %>. Import Namespace=”System.Collections.Generic” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <script runat=”server”>. FIGURE 10.3 Show list items with programmatic binding.. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <title>Programmatic DataBinding</title>. <form id=”form1” runat=”server”>. <asp:ListBox. id=”lstShoppingCart”. Runat=”server” />. ptg In Listing 10.3, the ListBox is bound to the collection in the Page_Load() method. Determining the Selected List Item. SelectedIndex— Gets or sets the...

ASP.NET 4 Unleased - p 49

tailieu.vn

ConnectionString=”<. Runat=”server” />. When you enable the AutoPostBack property, a JavaScript onchange() event handler is added to the List control. The DropDownList control has a SelectedIndexChanged event handler named. If you can’t use a mouse, and you are interact- ing with a website through the keyboard, having a page post back to the server whenev- er you make a selection...

ASP.NET 4 Unleased - p 50

tailieu.vn

LISTING 10.11 ShowListBox.aspx. <script runat=”server”>. <head id=”Head1” runat=”server”>. <title>Show ListBox</title>. <form id=”form1” runat=”server”>. <asp:ListBox id=”lstMovies”. Runat=”server” />. <asp:Button id=”btnSubmit”. <asp:Label id=”lblMovie”. <asp:SqlDataSource id=”srcMovies”. ConnectionString=”<. The ListBox control in Listing 10.11 includes a Rows property. The Rows property deter- mines the number of list items that the ListBox displays.. This is illustrated in the page in Listing 10.12 (see Figure 10.11).....

ASP.NET 4 Unleased - p 51

tailieu.vn

ptg LISTING 10.16 ShowBulletedListHyperLinks.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:BulletedList id=”blWebsites”. Runat=”server”>. <asp:ListItem Text=”Yahoo”. Value=”http://www.Yahoo.com” />. <asp:ListItem Text=”Google”. Value=”http://www.Google.com” />. <asp:ListItem Text=”Deja”. Value=”http://www.Deja.com” />. </asp:BulletedList>. In this section, we create a custom List control named the MultiSelectList control that renders two list boxes and an Add and Remove button. You can click...

ASP.NET 4 Unleased - p 52

tailieu.vn

<asp:Label. id=”lblSelected”. Runat=”server” />. In the page in Listing 10.19, the MultiSelectList control is bound to a SqlDataSource control, which represents the contents of the Movies database table. You can select movie titles in the MultiSelectList control by moving movie titles from one list box to the second list box. In this chapter, you learned how to use List controls...

ASP.NET 4 Unleased - p 53

tailieu.vn

<br style=”clear:both” />. <asp:SqlDataSource id=”srcEmployees”. ConnectionString=”<. Runat=”server” />. <asp:SqlDataSource. id=”srcEmployeeDetails”. Runat=”server”>. <asp:ControlParameter Name=”FirstName”. <asp:ControlParameter Name=”LastName”. </asp:SqlDataSource>. In Listing 11.4, the SelectedDataKey() method retrieves the primary key of the selected employee. The SelectedDataKey() method is used in both of the ControlParameters contained in the second SqlDataSource control. If you use SelectedValue() instead of SelectedDataKey() ,you can return only the value of...

ASP.NET 4 Unleased - p 54

tailieu.vn

<asp:ScriptManager ID=”sm1” runat=”server” />. DateTime.Now.ToString(“T”) %>. <asp:UpdatePanel ID=”up1” runat=”server”>. <asp:GridView id=”grdMovies”. Runat=”server” />. </asp:UpdatePanel>. <asp:SqlDataSource id=”srcMovies”. ConnectionString=”<. The page in Listing 11.10 includes an UpdatePanel control. Because the GridView is contained in the UpdatePanel , the page containing GridView is not posted back to the server when you page through GridView. The page in Listing 11.10 displays the current time...

ASP.NET 4 Unleased - p 55

tailieu.vn

If the value of the Title or Director columns has changed in the underlying database, the record is not updated. In other words, if someone else beats you to the record change, your modifications are ignored.. The page in Listing 11.14 includes an Updated event handler for the SqlDataSource control. AffectedRows property has the value 0.. GridView includes two properties...

ASP.NET 4 Unleased - p 56

tailieu.vn

ptg LISTING 11.18 ShowBoundField.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:GridView id=”grdMovies”. Runat=”server”>. <asp:BoundField DataField=”Title”. HeaderText=”Movie Title” />. <asp:BoundField. HeaderText=”Movie Director” />. HeaderText=”Box Office Totals” />. </asp:GridView>. <asp:SqlDataSource id=”srcMovies”. ConnectionString=”<. Runat=”server” />. In Listing 11.18, BoundFields display the Title, Director, and BoxOfficeTotals columns.. The BoundField used to display the BoxOfficeTotals column includes a...

ASP.NET 4 Unleased - p 57

tailieu.vn

For example, the page in Listing 11.22 displays a list of movie categories, and the page in Listing 11.23 displays a list of movies that match the selected category.. LISTING 11.22 Master.aspx. Page Language=”C#” %>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:GridView. id=”grdMovieCategories”. Runat=”server”>. <asp:HyperLinkField. DataNavigateUrlFormatString=”Details.aspx?id={0}” />. </asp:GridView>. <asp:SqlDataSource. id=”srcMovieCategories”. ConnectionString=”<. Runat=”server” />. LISTING 11.23 Details.aspx. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>....

asp.net 4 unleased - p 58

tailieu.vn

ptg 544 CHAPTER 11 Using the GridView Control. LISTING 11.27 ShowTemplateField.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:GridView id=”grdMovies”. Runat=”server”>. <asp:TemplateField HeaderText=”Title”>. FIGURE 11.19 Using TemplateField s with the GridView control.. Eval(“Title”) %>. <asp:TextBox id=”txtTitle”. Text=’<. Bind(“Title”) %>’. Runat=”server” />. <asp:RequiredFieldValidator id=”valTitle”. </asp:TemplateField>. <asp:TemplateField HeaderText=”Category”>. Eval(“Name”) %>. <asp:DropDownList id=”ddlCategory”. SelectedValue=’<. Bind(“CategoryId”) %>’. </asp:GridView>....

ASP.NET 4 Unleased - p 59

tailieu.vn

<form id=”form1” runat=”server”>. <asp:GridView id=”grdMovies”. Runat=”server”>. <asp:TemplateField>. Eval(“Name”) %></h1>. Runat=”server” />. <asp:SqlDataSource id=”srcMovies”. ConnectionString=”<. <asp:Parameter Name=”CategoryId” />. </asp:SqlDataSource>. </asp:TemplateField>. </asp:GridView>. <asp:SqlDataSource. id=”srcMovieCategories”. Like any other control in the ASP.NET Framework, if you don’t like any aspect of the GridView control, you always have the option of extending the control. To create a custom field, you can inherit a new class...