* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / Test / mainsoft / MainsoftWebApp / System_Web_UI_WebControls / DataGridColumn / DataGridColumn_HeaderImageUrl.aspx.cs
1 //
2 // Authors:
3 //   Rafael Mizrahi   <rafim@mainsoft.com>
4 //   Erez Lotan       <erezl@mainsoft.com>
5 //   Vladimir Krasnov <vladimirk@mainsoft.com>
6 //
7 //
8 // Copyright (c) 2002-2005 Mainsoft Corporation.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System;
31 using System.Data;
32 using System.Collections;
33 using System.Web;
34 using System.Web.UI;
35 using System.Web.UI.WebControls;
36 using System.Web.UI.HtmlControls;
37
38 namespace GHTTests.System_Web_dll.System_Web_UI_WebControls
39 {
40         public class DataGridColumn_HeaderImageUrl
41                 : GHTBaseWeb 
42         {
43                 #region Web Form Designer generated code
44                 override protected void OnInit(EventArgs e) 
45                 {
46                         //
47                         // CODEGEN: This call is required by the ASP.NET Web Form Designer.
48                         //
49                         InitializeComponent();
50                         base.OnInit(e);
51                 }
52                 
53                 /// <summary>
54                 /// Required method for Designer support - do not modify
55                 /// the contents of this method with the code editor.
56                 /// </summary>
57                 private void InitializeComponent() 
58                 {    
59                         this.Load += new System.EventHandler(this.Page_Load);
60                 }
61                 #endregion
62
63                 #region "Template Classes"
64                 public class t_DBLitTemplate : ITemplate
65                 {
66                         public void InstantiateIn(Control container)
67                         {
68                                 Literal literal1 = new Literal();
69                                 literal1.Text = "<div>";
70                                 literal1.DataBinding += new EventHandler(this.BindData);
71                                 container.Controls.Add(literal1);
72                         }
73                         public void BindData(object sender, EventArgs e)
74                         {
75                                 Literal literal1 = (Literal) sender;
76                                 DataGridItem item1 = (DataGridItem) literal1.NamingContainer;
77                                 literal1.Text = DataBinder.Eval(item1.DataItem, "Name") + "</div>";
78                         }
79                 }
80                 public class t_EmptyLitTemplate : ITemplate
81                 {
82                         public void InstantiateIn(Control container)
83                         {
84                                 Literal literal1 = new Literal();
85                                 literal1.Text = "";
86                                 container.Controls.Add(literal1);
87                         }
88                 }
89                 public class t_PlainTextLitTemplate : ITemplate
90                 {
91                         public void InstantiateIn(Control container)
92                         {
93                                 Literal literal1 = new Literal();
94                                 literal1.Text = "Plain text template create at run time";
95                                 container.Controls.Add(literal1);
96                         }
97                 }
98                 public class t_HtmlLitTemplate : ITemplate
99                 {
100                         public void InstantiateIn(Control container)
101                         {
102                                 Literal literal1 = new Literal();
103                                 literal1.Text = "<div><b><i>Html template created at run time</i></b></div>";
104                                 container.Controls.Add(literal1);
105                         }
106                 }
107                 public class t_ControlLitTemplate : ITemplate
108                 {
109                         public void InstantiateIn(Control container)
110                         {
111                                 HtmlInputButton button1 = new HtmlInputButton();
112                                 button1.Value = "Control template";
113                                 container.Controls.Add(button1);
114                         }
115                 }
116                 #endregion
117
118                 #region "DataGrid creation functions"
119                 private void setText(DataGridColumn c, ListItemType tp, string text)
120                 {
121                         switch (tp)
122                         {
123                                 case ListItemType.Header:
124                                 {
125                                         c.HeaderText = text;
126                                         return;
127                                 }
128                                 case ListItemType.Footer:
129                                 {
130                                         c.FooterText = text;
131                                         return;
132                                 }
133                         }
134                 }
135  
136                 private void setStyle(DataGridColumn c, ListItemType tp)
137                 {
138                         switch (tp)
139                         {
140                                 case ListItemType.Header:
141                                 {
142                                         c.HeaderStyle.VerticalAlign = VerticalAlign.Top;
143                                         c.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
144                                         c.HeaderStyle.Wrap = false;
145                                         return;
146                                 }
147                                 case ListItemType.Footer:
148                                 {
149                                         c.FooterStyle.VerticalAlign = VerticalAlign.Top;
150                                         c.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
151                                         c.FooterStyle.Wrap = false;
152                                         return;
153                                 }
154                                 case ListItemType.Item:
155                                 {
156                                         c.ItemStyle.VerticalAlign = VerticalAlign.Top;
157                                         c.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
158                                         c.ItemStyle.Wrap = false;
159                                         return;
160                                 }
161                         }
162                 }
163  
164                 private DataGridColumn c_bounded(string se)
165                 {
166                         BoundColumn column1 = new BoundColumn();
167                         column1.DataField = "ID";
168                         column1.HeaderImageUrl = se;
169                         return column1;
170                 }
171  
172                 private DataGridColumn c_button(string se)
173                 {
174                         ButtonColumn column1 = new ButtonColumn();
175                         column1.DataTextField = "ID";
176                         column1.HeaderImageUrl = se;
177                         return column1;
178                 }
179  
180                 private DataGridColumn c_hyper_link(string se)
181                 {
182                         HyperLinkColumn column1 = new HyperLinkColumn();
183                         column1.DataTextField = "ID";
184                         column1.NavigateUrl = "http://www.google.com";
185                         column1.HeaderImageUrl = se;
186                         return column1;
187                 }
188  
189                 private DataGridColumn c_edit(string se)
190                 {
191                         EditCommandColumn column1 = new EditCommandColumn();
192                         column1.EditText = "Edit";
193                         column1.HeaderImageUrl = se;
194                         return column1;
195                 }
196  
197                 private DataGridColumn c_template(string se)
198                 {
199                         TemplateColumn column1 = new TemplateColumn();
200                         column1.ItemTemplate = new DataGridColumn_HeaderImageUrl.t_DBLitTemplate();
201                         column1.HeaderImageUrl = se;
202                         return column1;
203                 }
204                 private void DataGridTest(string TestName, DataGridColumn c)
205                 {
206                         DataGrid grid1 = new DataGrid();
207                         this.GHTSubTestBegin(TestName);
208                         try
209                         {
210                                 grid1.Columns.Add(c);
211                                 grid1.DataSource = GHTTests.GHDataSources.DSDataTable();
212                                 grid1.ShowFooter = true;
213                                 grid1.DataBind();
214                                 base.GHTActiveSubTest.Controls.Add(grid1);
215                                 this.GHTSubTestAddResult(grid1.Columns[0].HeaderImageUrl);
216                         }
217                         catch (Exception exception2)
218                         {
219                                 // ProjectData.SetProjectError(exception2);
220                                 Exception exception1 = exception2;
221                                 this.GHTSubTestUnexpectedExceptionCaught(exception1);
222                                 grid1 = null;
223                                 //ProjectData.ClearProjectError();
224                         }
225                         this.GHTSubTestEnd();
226                 }
227  
228                 #endregion
229
230                 private void Page_Load(object sender, System.EventArgs e) 
231                 {
232                         //Put user code to initialize the page here
233
234                         System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
235                         GHTTestBegin(frm);
236
237                         DataGridTest("GhtSubTest1", c_bounded(""));
238                         DataGridTest("GhtSubTest2", c_button(""));
239                         DataGridTest("GhtSubTest3", c_edit(""));
240                         DataGridTest("GhtSubTest4", c_hyper_link(""));
241                         DataGridTest("GhtSubTest5", c_template(""));
242                         DataGridTest("GhtSubTest6", c_bounded("/images/pic.gif"));
243                         DataGridTest("GhtSubTest7", c_button("/images/pic.gif"));
244                         DataGridTest("GhtSubTest8", c_edit("/images/pic.gif"));
245                         DataGridTest("GhtSubTest9", c_hyper_link("/images/pic.gif"));
246                         DataGridTest("GhtSubTest10", c_template("/images/pic.gif"));
247                         DataGridTest("GhtSubTest11", c_bounded("http://127.0.0.1/asd/asd/../../asd.asd"));
248                         DataGridTest("GhtSubTest12", c_button("http://127.0.0.1/asd/asd/../../asd.asd"));
249                         DataGridTest("GhtSubTest13", c_edit("http://127.0.0.1/asd/asd/../../asd.asd"));
250                         DataGridTest("GhtSubTest14", c_hyper_link("http://127.0.0.1/asd/asd/../../asd.asd"));
251                         DataGridTest("GhtSubTest15", c_template("http://127.0.0.1/asd/asd/../../asd.asd"));
252                         DataGridTest("GhtSubTest16", c_bounded(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
253                         DataGridTest("GhtSubTest17", c_button(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
254                         DataGridTest("GhtSubTest18", c_edit(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
255                         DataGridTest("GhtSubTest19", c_hyper_link(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
256                         DataGridTest("GhtSubTest20", c_template(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
257
258
259                         GHTTestEnd();
260                 }
261         }
262 }