Literal.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: Literal
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: 100%
  10. *
  11. * (C) Gaurav Vaish (2001)
  12. */
  13. using System;
  14. using System.Web;
  15. using System.Web.UI;
  16. using System.ComponentModel;
  17. namespace System.Web.UI.WebControls
  18. {
  19. [DefaultProperty("Text")]
  20. [ControlBuilder(typeof(LiteralControlBuilder))]
  21. //[DataBindingHandler("??")]
  22. public class Literal : Control
  23. {
  24. public Literal () : base ()
  25. {
  26. }
  27. public string Text
  28. {
  29. get {
  30. object o = ViewState ["Text"];
  31. return (o == null) ? String.Empty : (string) o;
  32. }
  33. set { ViewState ["Text"] = value; }
  34. }
  35. protected override ControlCollection CreateControlCollection ()
  36. {
  37. return new EmptyControlCollection (this);
  38. }
  39. protected override void AddParsedSubObject (object obj)
  40. {
  41. if (!(obj is LiteralControl))
  42. throw new HttpException (HttpRuntime.FormatResourceString (
  43. "Cannot_Have_Children_Of_Type", "Literal",
  44. obj.GetType ().Name.ToString ()));
  45. Text = ((LiteralControl) obj).Text;
  46. }
  47. protected override void Render (HtmlTextWriter writer)
  48. {
  49. if (Text.Length > 0)
  50. writer.Write (Text);
  51. }
  52. }
  53. }