Q&A

Q. My web part is performing poorly and takes too much time to render. Is there any way I can monitor my code for performance bottlenecks?

A. Yes, you can do this easily using the SPMonitoredScope class, which helps you define your own monitored scope and display performance results on the developer dashboard. This is discussed more in Hour 8, “Understanding Client Object Model in SharePoint 2010.”

Q. Is there any way I can specify default values for my web part properties using an XML file?

A. Yes, you can specify default values in the .webpart file, which is an XML file that describes your web part and makes it available in the Web Part Gallery. You can add new properties under the properties tag and specify their values, or you can edit the values of any already existing properties. The file is created automatically for you when developing a web part in Visual Studio 2010.

Q. I want to develop a web part to connect to an already created web part. How do I know which interface I should implement?

A. In such a scenario, you should refer to the documentation for the existing web part as a first step. Otherwise, for the target web part examine the .webpart file in the Web Part Gallery and look for the assembly defining the underlying type by examining the value of the metadata element. Next you can reflect the assembly thus determined using the Red Gate’s reflector and look for the function decorated with the ConnectionConsumer or ConnectionProvider attribute, depending on the type of web part you are planning to create (that is, connection consumer or provider). By examining the signature of the function thus determined, you can find out the interface that your provider/consumer web part should implement.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset