Differences Between WebPartTitleID Between ASP.NET Web Pages and Sharepoint Websites

when I refer to Microsoft.SharePoint.WebPartPages.WebPart the WebPartTitleID is generated on pages in the following format. WebPartTitleWPQ2

when i link to System.Web.UI.WebControls.WebParts.WebPart

The WebPartTitleID is generated on the following pages:

WebPartTitlectl00_m_g_cfe73da2_e9aa_44e3_aa10_b8a300837217

Is there a way to control this so I am getting the WPQ template in the asp.net web part?

+1


a source to share


2 answers


As far as I know, there is no way to manage these auto-generated web part IDs. If you need to style them, the best I could do is wrap everything, it's a div with a custom id or class.



0


a source


Try the following:



string clientName = ((Microsoft.SharePoint.WebPartPages.WebPart)wp).ClientName;

string wpqId = clientName.Substring(clientName.IndexOf("WPQ"));

      

0


a source







All Articles