WEB PARTS: THE BUILDING BLOCKS OF PORTALS in Visual Studio .NET

Printing Data Matrix 2d barcode in Visual Studio .NET WEB PARTS: THE BUILDING BLOCKS OF PORTALS

WEB PARTS: THE BUILDING BLOCKS OF PORTALS
Data Matrix 2d Barcode Encoder In Visual Studio .NET
Using Barcode maker for ASP.NET Control to generate, create Data Matrix 2d barcode image in ASP.NET applications.
www.OnBarcode.com
Encoding Barcode In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Displaying calendar appointments In this next example a user control will be used to create a web part that displays the current date and time. The web page will also display information to the users about upcoming meetings from their calendars. In our example, however, we ll again use hard-coded sample data for simplicity rather than writing the code that would be required to connect to a real calendar. Figure 2.7 shows how this web part will appear when it s complete. From within your test web project, add a new user control file named MyCalendar.ascx to the project. To create the user interface elements necessary to display our control, add the markup that is displayed in listing 2.4 to the control.
Printing Barcode In .NET
Using Barcode creator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Drawing Matrix In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create 2D image in ASP.NET applications.
www.OnBarcode.com
Figure 2.7 A user control web part is used to display the current date and time. It also displays information about upcoming meetings for the logged-in user.
Make QR Code 2d Barcode In VS .NET
Using Barcode maker for ASP.NET Control to generate, create QR image in ASP.NET applications.
www.OnBarcode.com
UCC.EAN - 128 Creation In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create UCC.EAN - 128 image in ASP.NET applications.
www.OnBarcode.com
Listing 2.4 The HTML to display the calendar user interface
GS1 - 13 Creation In .NET
Using Barcode generation for ASP.NET Control to generate, create EAN / UCC - 13 image in ASP.NET applications.
www.OnBarcode.com
ITF-14 Printer In .NET Framework
Using Barcode generator for ASP.NET Control to generate, create UCC - 14 image in ASP.NET applications.
www.OnBarcode.com
<h3>Current Date and Time</h3> <div> <span style="width: 140px">Date: </span> <%= DateTime.Now.ToShortDateString() %> </div> <div> <span style="width: 140px">Time: </span> <%= DateTime.Now.ToShortTimeString() %> </div>
Data Matrix 2d Barcode Generation In Java
Using Barcode creator for Eclipse BIRT Control to generate, create Data Matrix ECC200 image in BIRT reports applications.
www.OnBarcode.com
ECC200 Creator In Java
Using Barcode printer for Android Control to generate, create ECC200 image in Android applications.
www.OnBarcode.com
The Date and Time interface elements
Painting Denso QR Bar Code In VS .NET
Using Barcode drawer for VS .NET Control to generate, create QR-Code image in .NET framework applications.
www.OnBarcode.com
Denso QR Bar Code Generator In Java
Using Barcode creator for Java Control to generate, create QR-Code image in Java applications.
www.OnBarcode.com
<h3>Upcoming Meetings</h3> <asp:Repeater ID="rptMeetings" runat="server"> <ItemTemplate> The Calendar <p> interface elements <b> <%# Eval("MeetingName") %></b> <br /> <span style="font-size: smaller; font-style: italic;"> <%# Eval("MeetingDateTime") %> </span> </p> </ItemTemplate> </asp:Repeater>
Code 39 Full ASCII Encoder In Visual C#.NET
Using Barcode generation for VS .NET Control to generate, create Code 39 Full ASCII image in Visual Studio .NET applications.
www.OnBarcode.com
Matrix 2D Barcode Generator In VB.NET
Using Barcode creator for .NET framework Control to generate, create Matrix 2D Barcode image in .NET framework applications.
www.OnBarcode.com
Listing 2.4 creates the presentation layout for the web part. As you can see, there is a Repeater server control named rptMeetings that binds to some fields named MeetingName and MeetingDateTime.
Make USS Code 128 In Objective-C
Using Barcode generation for iPad Control to generate, create Code128 image in iPad applications.
www.OnBarcode.com
EAN / UCC - 13 Creator In None
Using Barcode encoder for Font Control to generate, create European Article Number 13 image in Font applications.
www.OnBarcode.com
UNDERSTANDING THE WEBPART CLASS
Recognize Barcode In VB.NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Code 39 Extended Generator In None
Using Barcode maker for Online Control to generate, create USS Code 39 image in Online applications.
www.OnBarcode.com
Binding dynamic data I mentioned before that, in a real world situation, the data we are displaying would be coming from a live backend, line-of-business application such as a Customer Relationship (CRM) database that contains information about the contacts and customers of a business. However, in our example, those fields are going to come from some sample data held in a data table. To create the data and bind it to the repeater, switch to source code view and add the code displayed in listing 2.5 to the form:
UCC - 12 Generation In Objective-C
Using Barcode creator for iPhone Control to generate, create Universal Product Code version A image in iPhone applications.
www.OnBarcode.com
Universal Product Code Version A Maker In Visual C#
Using Barcode creator for VS .NET Control to generate, create UPC-A image in .NET framework applications.
www.OnBarcode.com
Listing 2.5 Data is created and is bound to the user interface elements of our Calendar web part control
protected override void OnLoad(EventArgs e) { base.OnLoad(e);
DataTable dt = new DataTable("MeetingData"); dt.Columns.Add("MeetingName", typeof(string)); dt.Columns.Add("MeetingDateTime", typeof(DateTime)); DataRow row1 = dt.NewRow(); row1["MeetingName"] = "AGM"; row1["MeetingDateTime"] = DateTime.Now.AddDays(.2); dt.Rows.Add(row1);
Add columns to a DataTable to store data Add some rows of data to the DataTable
Add some rows of data to the DataTable DataRow row2 = dt.NewRow(); row2["MeetingName"] = "Lunch with CEO"; row2["MeetingDateTime"] = DateTime.Now.AddDays(1.3); dt.Rows.Add(row2);
this.rptMeetings.DataSource = dt; this.rptMeetings.DataBind(); }
Bind the DataTable to the user interface
The code in listing 2.5 shows that a DataTable is created and two columns are added to it that will contain the information about meetings. Next, dummy data is appended to the table before we finally bind the table to our repeater control, which contains the user interface logic to display the data to the user. That completes the code for the user control. Now we can create a web page to display it in. Add a page to your test web project and, as with all web part pages, add a WebPartManager and a WebPartZone to the page. With the page in design mode, drag the user control that we just created from the Server Explorer onto the web part zone. Listing 2.6 shows how the page appears when displayed in source view. You can see that the designer has added a Register directive for the user control and also added the correct mark-up for the user control into the body of the ZoneTemplate. Build and run your page in a browser to view the results. They should appear as they did in figure 2.7. 44
WEB PARTS: THE BUILDING BLOCKS OF PORTALS
Listing 2.6 The MyCalendar user control web part is declared within the web part zone
<%@ Register Src="MyCalendar.ascx" TagName="MyCalendar" TagPrefix="uc1" %> <asp:WebPartZone ID="WebPartZone1" runat="server"> <ZoneTemplate> <uc1:MyCalendar id="MyCalendar1" runat="server" Title="My Calendar" /> </ZoneTemplate> </asp:WebPartZone>
Now you ve seen both options for creating web part controls. That is, you can either create them by using custom server controls and by inheriting from the base WebPart class, or you can use user controls. In a very short time we ve actually managed to build web parts by using both custom server controls and user controls. Ideally, as you ve been working through these samples you ve started thinking of all the different types of web parts that a real business might want to have displayed on its portal employee information, sales data, production figures, profit and loss data, and so on. As we move further into the book, you ll learn that the portal framework comes complete with a catalog to store all these parts. Then you will see that having too many web parts never presents a problem, because they can all be stored and easily retrieved from within the catalog gallery, ready to be displayed on a user s page at any time.
Copyright © OnBarcode.com . All rights reserved.