E xErcIsE 3 Creating Connected Web Parts in C#.NET

Generation QR-Code in C#.NET E xErcIsE 3 Creating Connected Web Parts

E xErcIsE 3 Creating Connected Web Parts
QR Code JIS X 0510 Drawer In C#
Using Barcode creation for .NET Control to generate, create QR-Code image in .NET applications.
www.OnBarcode.com
QR Code 2d Barcode Reader In C#.NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
In this exercise, you extend an existing application to enable connected Web Parts.
Encode Bar Code In C#.NET
Using Barcode encoder for .NET framework Control to generate, create barcode image in .NET framework applications.
www.OnBarcode.com
Recognize Barcode In Visual C#
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Continue editing the project you created in the previous exercise. Alternatively, you can open the completed Lesson 3, Exercise 2 project in the samples installed from the CD.
QR Code JIS X 0510 Drawer In VS .NET
Using Barcode creation for ASP.NET Control to generate, create QR-Code image in ASP.NET applications.
www.OnBarcode.com
Denso QR Bar Code Printer In VS .NET
Using Barcode creation for .NET framework Control to generate, create QR image in .NET framework applications.
www.OnBarcode.com
ChAPTER 5
QR-Code Creation In VB.NET
Using Barcode maker for .NET framework Control to generate, create QR-Code image in Visual Studio .NET applications.
www.OnBarcode.com
PDF417 Generation In C#
Using Barcode creation for .NET Control to generate, create PDF-417 2d barcode image in .NET applications.
www.OnBarcode.com
Input Validation and Site Navigation
Barcode Maker In C#.NET
Using Barcode encoder for VS .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
GTIN - 13 Printer In Visual C#
Using Barcode generator for VS .NET Control to generate, create UPC - 13 image in .NET framework applications.
www.OnBarcode.com
Create three new web user controls as follows:
Make UCC.EAN - 128 In C#
Using Barcode creation for .NET Control to generate, create UCC-128 image in .NET framework applications.
www.OnBarcode.com
2 Of 7 Code Drawer In C#
Using Barcode printer for .NET framework Control to generate, create Monarch image in VS .NET applications.
www.OnBarcode.com
getname Add a Label control with the text Please type your name. Add a TextBox control named nameTextbox. Then add a Button control named submitbutton and labeled submit. greetUser Add a Label control named greetingLabel. shownamebackwards Add a Label control named backwardsLabel with the text Enter name to see it spelled backwards.
Barcode Generator In None
Using Barcode encoder for Word Control to generate, create barcode image in Office Word applications.
www.OnBarcode.com
Draw Bar Code In Visual Basic .NET
Using Barcode generation for Visual Studio .NET Control to generate, create barcode image in Visual Studio .NET applications.
www.OnBarcode.com
3. 4.
Scan Bar Code In C#.NET
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Paint QR Code JIS X 0510 In None
Using Barcode creation for Software Control to generate, create QR Code image in Software applications.
www.OnBarcode.com
Open the code-behind file for the GetName control. Add code to capture the text the user types in the TextBoxName control when he or she clicks Submit. Next, add the System.Web.UI.WebControls.WebParts namespace to the control. Create a public method named GetUserName, and set the ConnectionProvider attribute. In this method, return the name the user typed. This control provides the user s name as data to the consumer controls. The following shows an example.
Code 39 Full ASCII Maker In Objective-C
Using Barcode maker for iPhone Control to generate, create Code39 image in iPhone applications.
www.OnBarcode.com
Drawing Code39 In None
Using Barcode drawer for Online Control to generate, create ANSI/AIM Code 39 image in Online applications.
www.OnBarcode.com
Sample of Visual Basic Code Partial Class GetName Inherits System.Web.UI.UserControl Private _name As String = String.Empty Protected Sub SubmitButton_Click_ (ByVal sender As Object, ByVal e As System.EventArgs) _ Handles SubmitButton.Click _name = NameTextBox.Text End Sub <ConnectionProvider("User name provider", "GetUserName")> _ Public Function GetUserName() As String Return _name End Function End Class Sample of C# Code private string _name = string.Empty; protected void SubmitButton_Click(object sender, EventArgs e) { _name = NameTextBox.Text; } [ConnectionProvider("User name provider", "GetUserName")] public string GetUserName() { return _name; }
Code 128A Maker In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create Code 128A image in ASP.NET applications.
www.OnBarcode.com
QR Code ISO/IEC18004 Drawer In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
www.OnBarcode.com
Lesson 3: Using Web Parts
ChAPTER 5
Open the code-behind file for the GreetUser control. Add the System.Web.UI.WebControls. WebParts namespace to the code-behind file, and then create a public method named GetName and set the ConnectionConsumer attribute. This control reads the user s name from the GetName control (after the user is connected) and displays it to the user as part of a greeting. Create the GetName method so that it accepts a string and uses it to create a greeting by using the Label control, as the following code demonstrates.
Sample of Visual Basic Code Partial Class GreetUser Inherits System.Web.UI.UserControl <ConnectionConsumer("User name consumer", "GetName")> _ Public Sub GetName(ByVal Name As String) GreetingLabel.Text = "Welcome, " + Name + "!" End Sub End Class Sample of C# Code public partial class GreetUser : System.Web.UI.UserControl { [ConnectionConsumer("User name consumer", "GetName")] public void GetName(string Name) { GreetingLabel.Text = "Welcome, " + Name + "!"; } }
Open the code-behind file for the ShowNameBackwards control. Add the using statement for the System.Web.UI.WebControls.WebParts namespace. Then create a public GetName method as you did for GreetUser. You can use a similar definition for the ConnectionConsumer attribute. Inside this method, write code to reverse the order of the user s name and display it in the LabelBackwards control, as the following code demonstrates.
Sample of Visual Basic Code Partial Class ShowNameBackwards Inherits System.Web.UI.UserControl <ConnectionConsumer("User name consumer", "GetName")> _ Public Sub GetName(ByVal Name As String) Dim NameCharArray As Char() = Name.ToCharArray() Array.Reverse(NameCharArray) BackwardsLabel.Text = "Your name backward is: " & _ New String(NameCharArray) End Sub End Class
ChAPTER 5
Input Validation and Site Navigation
Sample of C# Code public partial class ShowNameBackwards : System.Web.UI.UserControl { [ConnectionConsumer("User name consumer", "GetName")] public void GetName(string Name) { char[] NameCharArray = Name.ToCharArray(); Array.Reverse(NameCharArray); BackwardsLabel.Text = "Your name backward is: " + new string(NameCharArray); } }
Open the Default2.aspx page you created in Design view, and add the GetName, GreetUser, and ShowNameBackwards controls to the bottom zone. Specify titles for each control, as shown here.
<asp:WebPartZone ID="WebPartZoneBottom" runat="server" HeaderText="Bottom Zone" style="width: 700px; height: auto;"> <ZoneTemplate> <uc3:GetName ID="GetName1" runat="server" title="Enter Name" /> <uc4:GreetUser ID="GreetUser1" runat="server" title="Greeting" /> <uc5:ShowNameBackwards ID="ShowNameBackwards1" runat="server" title="Backwards Name" /> </ZoneTemplate> </asp:WebPartZone>
Open Default2.aspx in Source view. Within the WebPartManager control, add a <StaticConnections> element. Within the <StaticConnections> element, add two WebPartConnection controls that declare the connections between the GetName provider and the GreetUser and ShowNameBackwards consumers. The WebPartConnection control must have an ID attribute, an attribute to identify the provider control (ProviderID), an attribute to identify the provider method (ProviderConnectionPointID), an attribute to identify the consumer control (ConsumerID), and an attribute to identify the consumer method (ConsumerConnectionPointID). The following markup demonstrates this.
<asp:webPartManager ID="webPartManager1" runat="server"> <StaticConnections> <asp:webPartConnection ID="WebPartConnection1" ProviderID="GetName1" ProviderConnectionPointID="GetUserName" ConsumerID="GreetUser1" ConsumerConnectionPointID="GetName" /> <asp:webPartConnection ID="WebPartConnection2" ProviderID="GetName1" ProviderConnectionPointID="GetUserName"
Copyright © OnBarcode.com . All rights reserved.