Control.ClientID has wrong value

Control.ClientID has wrong value

An ASP.NET Controls has a ClientID property. SharePoint Controls inherit from the ASP.NET Controls. The property will give you the ID, the rendered control will have in the HTML source. There is one thing to remember:

The ClientID is valid only, if the control has been added to the Controls of the Page!

ID before adding the controlID after adding the control
FilterButtonctl00_m_Webpart1_FilterButton

So if you need the ClientID e.g. to pass it to a JavaScript to be able to find the control, make sure you grab the ClientID after the control has been added to the Page.

Leave a Reply