File: default.aspx.cs

package info (click to toggle)
mono-reference-assemblies 3.12.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 604,240 kB
  • ctags: 625,505
  • sloc: cs: 3,967,741; xml: 2,793,081; ansic: 418,042; java: 60,435; sh: 14,833; makefile: 11,576; sql: 7,956; perl: 1,467; cpp: 1,446; yacc: 1,203; python: 598; asm: 422; sed: 16; php: 1
file content (117 lines) | stat: -rw-r--r-- 3,967 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _default : System.Web.UI.Page
{
	protected void Page_Load (object sender, EventArgs e)
	{
		var list = new List<string> {
		    "One",
		    "Two",
		    "Three"
		};

		try {
			GetUniqueIDRelativeTo (null);
		} catch (ArgumentNullException ex) {
			log.InnerText += String.Format ("Page; Relative to: null; Result: exception {0} (expected)\n", ex.GetType ());
		} catch (Exception ex) {
			log.InnerText += String.Format ("Page; Relative to: null; Result: exception {0}\n", ex.GetType ());
		}

		var ctl = new Control ();
		try {
			ctl.GetUniqueIDRelativeTo (this);
		} catch (InvalidOperationException ex) {
			log.InnerText += String.Format ("A control; Relative to: {0}; Result: exception {1} (expected)\n", this.UniqueID, ex.GetType ());
		} catch (Exception ex) {
			log.InnerText += String.Format ("A control; Relative to: {0}; Result: exception {1}\n", this.UniqueID, ex.GetType ());
		}

		try {
			textBox1.GetUniqueIDRelativeTo (this);
		} catch (InvalidOperationException ex) {
			log.InnerText += String.Format ("TextBox; Relative to: {0}; Result: exception {1} (expected)\n", this.UniqueID, ex.GetType ());
		} catch (Exception ex) {
			log.InnerText += String.Format ("TextBox; Relative to: {0}; Result: exception {1}\n", this.UniqueID, ex.GetType ());
		}

		repeater1.DataSource = list;
		repeater1.DataBind ();
	}

	protected void OnItemDataBound_Repeater1 (object sender, RepeaterItemEventArgs args)
	{
		if (args.Item.ItemType == ListItemType.Separator)
			return;
		
		int index = args.Item.ItemIndex;
		var sb = new StringBuilder ();
		Label label = args.Item.FindControl ("label1") as Label;

		string id = label.GetUniqueIDRelativeTo (args.Item);
		LogItem (index, label, args.Item, sb);

		id = label.GetUniqueIDRelativeTo (repeater1);
		LogItem (index, label, repeater1, sb);

		try {
			id = label.GetUniqueIDRelativeTo (this);
		} catch (InvalidOperationException ex) {
			sb.AppendFormat ("Item: {0}; Relative to: {1}; Result: exception {2} (expected)\n", args.Item.ItemIndex, this.UniqueID, ex.GetType ());
		} catch (Exception ex) {
			sb.AppendFormat ("Item: {0}; Relative to: {1}; Result: exception {2}\n", args.Item.ItemIndex, this.UniqueID, ex.GetType ());
		}

		log.InnerText += sb.ToString ();

		int listStart = index * 3;
		var list = new List<int> {
			listStart,
			listStart + 1,
			listStart + 2
		};
		Repeater innerRepeater = args.Item.FindControl ("innerRepeater1") as Repeater;
		innerRepeater.DataSource = list;
		innerRepeater.DataBind ();
	}

	protected void OnItemDataBound_InnerRepeater1 (object sender, RepeaterItemEventArgs args)
	{
		if (args.Item.ItemType == ListItemType.Separator)
			return;

		int index = args.Item.ItemIndex;
		var sb = new StringBuilder ();
		Label label = args.Item.FindControl ("innerLabel1") as Label;

		string id = label.GetUniqueIDRelativeTo (args.Item);
		LogItem (index, label, args.Item, sb, "\t");

		id = label.GetUniqueIDRelativeTo (repeater1);
		LogItem (index, label, repeater1, sb, "\t");

		id = label.GetUniqueIDRelativeTo (args.Item.Parent);
		LogItem (index, label, args.Item.Parent, sb, "\t");

		try {
			id = label.GetUniqueIDRelativeTo (this);
		} catch (InvalidOperationException ex) {
			sb.AppendFormat ("\tItem: {0}; Relative to: {1}; Result: exception {2} (expected)\n", args.Item.ItemIndex, this.UniqueID, ex.GetType ());
		} catch (Exception ex) {
			sb.AppendFormat ("\tItem: {0}; Relative to: {1}; Result: exception {2}\n", args.Item.ItemIndex, this.UniqueID, ex.GetType ());
		}

		log.InnerText += sb.ToString ();
	}

	void LogItem (int index, Control ctl, Control relativeTo, StringBuilder sb, string indent = "")
	{
		string id = ctl.GetUniqueIDRelativeTo (relativeTo);
		sb.AppendFormat ("{0}Item: {1}; Relative to: {2}; Result: '{3}'\n", indent, index, relativeTo.UniqueID, id);
	}
}