GetUniqueIDRelativeTo() public method

public GetUniqueIDRelativeTo ( Control control ) : string
control Control
return string
Exemplo n.º 1
0
	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 ();
	}
Exemplo n.º 2
0
	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);
	}