Determine the property name in a SharePoint Webpar

2019-08-28 06:00发布

I'm employing a custom webpart that is made by an unaffiliated third party. I've created a feature which adds this webpart to a page. It's working mostly fine, except that I can't figure out the name of a specific property that needs to be defined. I tried obvious ones that match the display name on the tool pane view, adding the company's name in front of said display name, and many similar permutations. All of which to no avail. I would much prefer to include the property to the feature, as this will be necessary to deploy across multiple sites in the future. Manually configuring it every time will be a pain for my client.

The short, obvious answer is "Ask the third party". This can potentially work, particularly for this specific one (it is a CodePlex webpart and the author has posted a comment as recent as last week). But my experience with previous third party solutions has been less than optimal, usually even getting no response until they ask me three weeks later if I still like their product. So, since this is not always a reliable method to obtain this information, I was thinking the best option is to find out a way to figure out the name of properties in a webpart that I can use not just with this particular one, but in all future situations.

I did check out this earlier question which addresses a similar topic. However, I don't have access to the class for the webpart so I can't just find a convenient property in the code to modify. Or, at least, if I do have access to it in some fashion, I'm certainly unaware of it.

Thank you in advance!

1条回答
混吃等死
2楼-- · 2019-08-28 06:41

From what I understand, you are trying to set a certain webpart property for which you do not know the corresponding XML attribute name.

Did you try to export the web part? One possible check might be to try to export the webpart to see what properties come up in the webpart XML. If it is a common property, chances are the webpart XML will have that property already defined with no value e.g.

<data>
   <properties>
     <property name="Your property Name" type="yourType"></property>
   <properties>
</data>

To export the webpart, go to Edit Page mode, click the down arrow on the webpart and choose Export.

Also, if you have the webpart code in a dll, can you use reflector to open it and see what properties are being set in code?

Hope this helps.

查看更多
登录 后发表回答