DataBoundLiteralControl.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // System.Web.UI.DataBoundLiteralCOntrol.cs
  3. //
  4. // Authors:
  5. // Duncan Mak ([email protected])
  6. // Gonzalo Paniagua Javier ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc. (http://www.ximian.com)
  9. //
  10. using System;
  11. using System.Text;
  12. namespace System.Web.UI {
  13. public sealed class DataBoundLiteralControl : Control
  14. {
  15. private string [] staticLiterals;
  16. private string [] dataBoundLiterals;
  17. public DataBoundLiteralControl (int staticLiteralsCount,
  18. int dataBoundLiteralCount)
  19. {
  20. staticLiterals = new string [staticLiteralsCount];
  21. dataBoundLiterals = new string [dataBoundLiteralCount];
  22. PreventAutoID ();
  23. }
  24. public string Text {
  25. get {
  26. StringBuilder text = new StringBuilder ();
  27. int stLength = staticLiterals.Length;
  28. int dbLength = dataBoundLiterals.Length;
  29. int max = (stLength > dbLength) ? stLength : dbLength;
  30. for (int i = 0; i < max; i++){
  31. if (i < stLength)
  32. text.Append (staticLiterals [i]);
  33. if (i < dbLength)
  34. text.Append (dataBoundLiterals [i]);
  35. }
  36. return text.ToString ();
  37. }
  38. }
  39. protected override ControlCollection CreateControlCollection ()
  40. {
  41. return new EmptyControlCollection (this);
  42. }
  43. [MonoTODO]
  44. protected override void LoadViewState (object savedState)
  45. {
  46. throw new NotImplementedException ();
  47. }
  48. protected override void Render (HtmlTextWriter output)
  49. {
  50. output.Write (Text);
  51. }
  52. [MonoTODO]
  53. protected override object SaveViewState ()
  54. {
  55. throw new NotImplementedException ();
  56. }
  57. public void SetDataBoundString (int index, string s)
  58. {
  59. dataBoundLiterals [index] = s;
  60. }
  61. public void SetStaticString (int index, string s)
  62. {
  63. staticLiterals [index] = s;
  64. }
  65. }
  66. }