BaseSocialControl

BaseSocialControl is a basic class containing a number of virtual methods with which to override provider-specific implementations.

  • Methods
    • RegisterGlobalSettings()
      Returns: string

      This method gets called for the first control in an ASP.NET page. It is designed to return Javascript that gets called once and specifies page-wide settings for your given control instance/s.
      In the instance of ShareThis, for example, parameters such as headerTitle, headerBg and headerFg only apply to a single widget, which is an iframe dynamically embedded in the page by ShareThis code.
    • RenderControl(HtmlWriter output)
      Returns: void

      The meat of the control. This is where you write to output anything your control needs to function - specific DOM elements, additional Javascript, etc.
      In ShareThis, this is where a CssClass is set, CSS attributes are determined for styling, and Javascript outputted to apply the CSS after ShareThis has dynamically generated further DOM code.
      Ultimately inheriting from WebControl, the default tag for a social control is <span>. To change it, see TagName.
  • Properties
    • LoaderUrl
      Returns: string

      Every social provider serves up a single file of Javascript which performs the necessary DOM manipulation, configuration management, etc. - that <script src="..."> you have to put on every page where you want to embed a social control.
      This is where you specify the URL to that Javascript file, where it will be automatically added to your page.
    • ControlName
      Returns: string

      This is more for internal use. All Javascript is registered using the Page.ClientScript static class methods. LoaderUrl and Javascript returned from RegisterGlobalSettings() are injected into the page using RegisterClientScriptInclude (executed on the control's PreRender event), while per-control settings should be injected using RegisterClientScriptBlock in the RenderControl method.
      To ensure non-collision of scripts, ControlName is used to append a prefix to each script registered. This means one can use multiple social controls on a page and all scripts are registered correctly without colliding or being over-written.

Last edited Jan 5, 2011 at 11:38 PM by codegecko, version 3

Comments

No comments yet.