开发者

How to Set a Fixed ID to the SharePoint WebPart Div?

开发者 https://www.devze.com 2023-02-03 16:52 出处:网络
I\'ve created an empty visual webpart in sharepoint 2010 and it\'s rendered like this: width=\"100%\" id=\"WebPartctl00_m_g_2c05f3a9_2b15_466c_bd32_479ac15c19c6\" haspers=\"false\"

I've created an empty visual webpart in sharepoint 2010 and it's rendered like this:

width="100%" id="WebPartctl00_m_g_2c05f3a9_2b15_466c_bd32_479ac15c19c6" haspers="false"

webpartid2="2c05f3a9-2b15-466c-bd32-479ac15c19c6" webpartid="7cc8033b-a2eb-4cd8-90d8-28fb3bc52112">

Contents here

开发者_运维百科

As can be seen, SharePoint renders 2 nested divs with auto generated ids.

How is it possible to set a fixed id to either of these divs?

Many thanks in advance,


Its not possible. Why do you need it? If you need it for styling, just emit your contents encapsulated inside a custom div from the web Part.

Alternatively, if you want the style to be applied on all web Parts , override the sharepoint styles which are applied on all web parts.

Check out this useful CSS guide for sharepoint: http://www.heathersolomon.com/content/sp07cssreference.htm


I believe that the GUID in the div is a reference to how the web parts are stored in the webpartmanager in asp.net.

http://msdn.microsoft.com/en-us/library/h8dcy47h%28v=VS.80%29.aspx

This is different for each placement of the webpart, so I'm not sure that hard coding the GUID is a good idea, or even possible.

0

精彩评论

暂无评论...
验证码 换一张
取 消