Configuration of Web Parts in .NET framework

Painting QR Code JIS X 0510 in .NET framework Configuration of Web Parts
Configuration of Web Parts
Creating QR Code JIS X 0510 In .NET
Using Barcode printer for .NET framework Control to generate, create QR-Code image in Visual Studio .NET applications.
tion between the closing element </SharePoint> and the opening element <systemweb> in the webconfig Listing 9-17 shows a sample connectionStrings section The name of the connection string is MyConnectionString and the connectionString attribute stores the actual connection string
QR Code JIS X 0510 Scanner In VS .NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
Listing 9-17: connectionStrings Section
Generating Barcode In VS .NET
Using Barcode drawer for .NET framework Control to generate, create barcode image in .NET applications.
              
Recognizing Bar Code In .NET Framework
Using Barcode reader for VS .NET Control to read, scan read, scan image in .NET framework applications.
For the purpose of readability you can see the password for the connection string in Listing 9-17, but in production environments you should always encrypt passwords before storing them in the webconfig file For more information about how to encrypt a password in a file, see http:// msdnmicrosoftcom/en-us/library/ms178372aspx You can read the connection string during runtime in your web part by using the WebConfigurationManager object available in the SystemWeb Configuration namespace and use its ConnectionStrings collection to access the element containing the connection string All you need to do is reference SystemConfiguration to your code and add a using directive for it The following line shows you how to access the connection string in code
Generate QR Code In Visual C#.NET
Using Barcode printer for .NET framework Control to generate, create QR Code image in VS .NET applications.
      
Making QR Code In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create QR-Code image in ASP.NET applications.
The only problem with our approach so far is that you need to manually add the connection string element to the connectionStrings section in the webconfig This also needs to be done in the webconfig files of the target web applications on the destination servers Another approach for adding connection strings to the connectionStrings section of the webconfig file is to use the SPWebConfigModification class in a feature event receiver to make changes to the SharePoint webconfig
Generate QR Code JIS X 0510 In VB.NET
Using Barcode maker for .NET framework Control to generate, create QR Code 2d barcode image in .NET framework applications.
9: SharePoint Web Parts
Generating EAN 13 In .NET Framework
Using Barcode maker for VS .NET Control to generate, create UPC - 13 image in Visual Studio .NET applications.
file automatically Using a feature event receiver has the advantage that the connection strings will be automatically added to the webconfig files at the destination servers when the feature is activated and also can be removed when the feature is deactivated (for more information on feature event receivers see 5, SharePoint Event Receivers ) Listing 9-18 shows the code that adds a connection string to the connectionStrings section in the webconfig in a FeatureActivated event handler
Print Bar Code In Visual Studio .NET
Using Barcode drawer for .NET Control to generate, create barcode image in .NET applications.
Listing 9-18: Code for Adding a Connection String to the connectionStrings Section in the webconfig
Code 128A Creation In Visual Studio .NET
Using Barcode drawer for .NET Control to generate, create Code-128 image in .NET applications.
                                                                 
ECC200 Maker In Visual Studio .NET
Using Barcode creation for Visual Studio .NET Control to generate, create Data Matrix 2d barcode image in .NET framework applications.
In order to access the webconfig and make updates we need to get the current web application first We want the modifications to apply to all web applications in a farm so we create an object of SPWebService rather than accessing the farm instance through SPWebApplication SPWebService serves as a container for all the web applications in a SharePoint farm After that we create the SPWebConfigModification object The Path
Generating USPS POSTNET Barcode In Visual Studio .NET
Using Barcode creation for Visual Studio .NET Control to generate, create Postnet 3 of 5 image in VS .NET applications.
Configuration of Web Parts
Data Matrix ECC200 Scanner In Visual Studio .NET
Using Barcode reader for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
property sets an XPath expression that is used to locate the node that is being modified or created, which is in our case the connectionStrings section node The Name property sets the name of the attribute or section node to be modified or created, which is the attributes name in our case and connectionString The Sequence property is set to 0 because we only have one notification If we had more we would need to increment the sequence number The Owner property needs a unique string, which we set in our sample to UniqueOwner The modification type is set to EnsureChildNode, which basically makes sure that there is a child node Other values for the modification type are EnsureSection and EnsureAttribute When creating a new section you should use the EnsureChildNode modification type value instead of EnsureSection EnsureChildNode will allow us to remove the section programmatically if needed The Value property contains the actual value of our connection string Next we must add the modification object to the WebConfigModifications collection of the service object and call the Update method on the service object The Update method causes this web service to save its state and to propagate changes to all the machines in the farm Finally we call the ApplyWebConfigModifications method on the service object, which applies the list of webconfig modifications to all web applications in this web service across the farm
EAN128 Printer In Java
Using Barcode encoder for Java Control to generate, create EAN / UCC - 13 image in Java applications.
Create Data Matrix 2d Barcode In VB.NET
Using Barcode printer for .NET framework Control to generate, create Data Matrix 2d barcode image in VS .NET applications.
Recognize Code-128 In VS .NET
Using Barcode reader for .NET Control to read, scan read, scan image in .NET applications.
Barcode Encoder In .NET
Using Barcode generation for ASP.NET Control to generate, create bar code image in ASP.NET applications.