FocusExtender.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.Collections.Generic;
  11. namespace Samples.CS
  12. {
  13. [TargetControlType(typeof(Control))]
  14. public class FocusExtender : ExtenderControl
  15. {
  16. private string _highlightCssClass;
  17. private string _noHighlightCssClass;
  18. public string HighlightCssClass
  19. {
  20. get { return _highlightCssClass; }
  21. set { _highlightCssClass = value; }
  22. }
  23. public string NoHighlightCssClass
  24. {
  25. get { return _noHighlightCssClass; }
  26. set { _noHighlightCssClass = value; }
  27. }
  28. protected override IEnumerable<ScriptReference> GetScriptReferences()
  29. {
  30. ScriptReference reference = new ScriptReference();
  31. reference.Path = ResolveClientUrl("FocusBehavior.js");
  32. return new ScriptReference[] { reference };
  33. }
  34. protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors(Control targetControl)
  35. {
  36. ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("Samples.FocusBehavior", targetControl.ClientID);
  37. descriptor.AddProperty("highlightCssClass", this.HighlightCssClass);
  38. descriptor.AddProperty("nohighlightCssClass", this.NoHighlightCssClass);
  39. return new ScriptDescriptor[] { descriptor };
  40. }
  41. }
  42. }