Guest User

Untitled

a guest
Dec 11th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. using System;
  2. using System.Web.UI;
  3. using System.Web.UI.WebControls;
  4. using System.Collections.Generic;
  5.  
  6. using System.Xml;
  7.  
  8. namespace BillMatrix.Customers.Biller.ConsumerWeb
  9. {
  10. public partial class Banner : System.Web.UI.UserControl
  11. {
  12. // Private vars and default values
  13. private string _scenario;
  14. private string _source;
  15. private string _link = "#";
  16. private string _class = "dynamic-banner";
  17. private string _target = "_blank";
  18. private string _width = "0";
  19. private string _height = "0";
  20. private string _text = "";
  21. private HyperLink _hl = new HyperLink();
  22.  
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. ReadXMLDocument(_scenario);
  26. }
  27.  
  28. // Find the scenario in the XML file, grab the attributes listed there,
  29. // and populate the phBanner element with a new banner.
  30. private void ReadXMLDocument(string scenario)
  31. {
  32. XmlDocument bannerDoc = new XmlDocument();
  33. bannerDoc.Load(Server.MapPath("~/ewallet/BannerConfig.xml"));
  34.  
  35. XmlNodeList scenarioGroup = bannerDoc.SelectNodes("//banners/scenario[@type='" + Scenario + "']");
  36.  
  37. // Are there any scenarios that match?
  38. if (scenarioGroup.Count > 0)
  39. {
  40. bannerPnl.Visible = true;
  41.  
  42. foreach (XmlNode node in scenarioGroup)
  43. {
  44. Source = node["bannersrc"].InnerText;
  45. Link = node["bannerlink"].InnerText;
  46. Class = node["class"].InnerText;
  47. Width = node["width"].InnerText;
  48. Height = node["height"].InnerText;
  49. Text = node["text"].InnerText;
  50. Target = node["target"].InnerText;
  51.  
  52. _hl.NavigateUrl = Link;
  53. _hl.CssClass = Class;
  54. _hl.Style.Add("background" , "url('" + Source + "') left top no-repeat;");
  55. _hl.Style.Add("width" , Width + "px");
  56. _hl.Style.Add("padding-top" , Height + "px;");
  57. _hl.Text = Text;
  58. _hl.Target = Target;
  59. }
  60.  
  61. phBanner.Controls.Add(_hl);
  62. }
  63.  
  64. }
  65.  
  66. public string Scenario
  67. {
  68. get { return _scenario; }
  69. set { _scenario = value; }
  70. }
  71.  
  72. public string Source
  73. {
  74. get { return _source; }
  75. set { _source = value; }
  76. }
  77.  
  78. public string Link
  79. {
  80. get { return _link; }
  81. set
  82. {
  83. if (value != "")
  84. {
  85. _link = value;
  86. }
  87. }
  88. }
  89.  
  90. public string Class
  91. {
  92. get { return _class; }
  93. set {
  94. if (value != "")
  95. {
  96. _class = value;
  97. }
  98. }
  99. }
  100.  
  101. public string Width
  102. {
  103. get { return _width; }
  104. set
  105. {
  106. if (value != "")
  107. {
  108. _width = value;
  109. }
  110. }
  111. }
  112.  
  113. public string Height
  114. {
  115. get { return _height; }
  116. set
  117. {
  118. if (value != "")
  119. {
  120. _height = value;
  121. }
  122. }
  123. }
  124.  
  125. public string Text
  126. {
  127. get { return _text; }
  128. set
  129. {
  130. if (value != "")
  131. {
  132. _text = value;
  133. }
  134. }
  135. }
  136.  
  137. public string Target
  138. {
  139. get { return _target; }
  140. set
  141. {
  142. if (value != "")
  143. {
  144. _target = value;
  145. }
  146. }
  147. }
  148.  
  149. }
  150. }
Add Comment
Please, Sign In to add comment