public void ThisIsADGTest() { DataGridTest p = new DataGridTest(); DataTable table = new DataTable(); EditCommandColumn e; string markup; e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.LinkButton; e.CancelText = "Cancel"; e.EditText = "Edit"; e.UpdateText = "Update"; table.Columns.Add(new DataColumn("one", typeof(string))); table.Columns.Add(new DataColumn("two", typeof(string))); table.Columns.Add(new DataColumn("three", typeof(string))); table.Rows.Add(new object [] { "1", "2", "3" }); p.DataSource = new DataView(table); p.Columns.Add(e); e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.PushButton; e.CancelText = "Abbrechen"; e.EditText = "Bearbeiten"; e.UpdateText = "Refresh"; p.Columns.Add(e); p.CreateControls(true); // This is the test we want to run: setting the ID of the table created by // the datagrid overrides the using the ID of the datagrid itself and uses // the table ClientID instead. p.ID = "sucker"; p.Controls [0].ID = "tbl"; Assert.AreEqual(2, p.Columns.Count, "I1"); markup = ControlMarkup(p.Controls[0]); markup = markup.Replace("\t", ""); markup = markup.Replace("\r", ""); markup = markup.Replace("\n", ""); #if NET_2_0 HtmlDiff.AssertAreEqual( "<table border=\"0\"><tr><td> </td><td> </td><td>one</td><td>two</td><td>three</td>" + "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker_tbl$ctl02$ctl00\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + "</tr><tr><td> </td><td> </td><td> </td><td> </td><td> </td>" + "</tr></table>", markup, "I2"); #else Assert.AreEqual( "<table border=\"0\" id=\"sucker_tbl\"><tr><td> </td><td> </td><td>one</td><td>two</td><td>three</td>" + "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker:_ctl1:_ctl0\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + "</tr><tr><td> </td><td> </td><td> </td><td> </td><td> </td>" + "</tr></table>", markup, "I2"); #endif }
public void InitializeCell() { DataGridTest p = new DataGridTest(); DataTable table = new DataTable(); EditCommandColumn e; string markup; e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.LinkButton; e.CancelText = "Cancel"; e.EditText = "Edit"; e.UpdateText = "Update"; table.Columns.Add(new DataColumn("one", typeof(string))); table.Columns.Add(new DataColumn("two", typeof(string))); table.Columns.Add(new DataColumn("three", typeof(string))); table.Rows.Add(new object [] { "1", "2", "3" }); p.DataSource = new DataView(table); p.Columns.Add(e); e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.PushButton; e.CancelText = "Abbrechen"; e.EditText = "Bearbeiten"; e.UpdateText = "Refresh"; p.Columns.Add(e); // This will trigger EditCommandColumn.InitializeCell, without any EditItem set, tests the EditText render p.CreateControls(true); p.ID = "sucker"; Assert.AreEqual(2, p.Columns.Count, "I1"); markup = ControlMarkup(p.Controls[0]); markup = markup.Replace("\t", ""); markup = markup.Replace("\r", ""); markup = markup.Replace("\n", ""); #if NET_2_0 HtmlDiff.AssertAreEqual( "<table border=\"0\"><tr><td> </td><td> </td><td>one</td><td>two</td><td>three</td>" + "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + "</tr><tr><td> </td><td> </td><td> </td><td> </td><td> </td>" + "</tr></table>", markup, "I2"); #else Assert.AreEqual( "<table border=\"0\" id=\"sucker\"><tr><td> </td><td> </td><td>one</td><td>two</td><td>three</td>" + "</tr><tr><td><a>Edit</a></td><td><input name=\"sucker:_ctl1:_ctl0\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td>" + "</tr><tr><td> </td><td> </td><td> </td><td> </td><td> </td>" + "</tr></table>", markup, "I2"); #endif //ShowControlsRecursive (p.Controls [0], 1); }
public void InitializeReadOnlyEditCell() { DataGridTest p = new DataGridTest(); DataTable table = new DataTable(); EditCommandColumn e; string markup; e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.LinkButton; e.CancelText = "Cancel"; e.EditText = "Edit"; e.UpdateText = "Update"; table.Columns.Add(new DataColumn("one", typeof(string))); table.Columns.Add(new DataColumn("two", typeof(string))); table.Columns.Add(new DataColumn("three", typeof(string))); table.Rows.Add(new object[] { "1", "2", "3" }); p.DataSource = new DataView(table); p.Columns.Add(e); e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.PushButton; e.CancelText = "Abbrechen"; e.EditText = "Bearbeiten"; e.UpdateText = "Refresh"; p.Columns.Add(e); // Force the ListItemType to be EditItem so we can test rendering the UpdateText/CancelText render p.EditItemIndex = 0; // This will trigger EditCommandColumn.InitializeCell p.CreateControls(true); p.ID = "sucker"; markup = ControlMarkup(p.Controls[0]); markup = markup.Replace("\t", ""); markup = markup.Replace("\r", ""); markup = markup.Replace("\n", ""); Assert.AreEqual(2, p.Columns.Count, "I1"); Assert.AreEqual( "<table border=\"0\" id=\"sucker\"><tr><td> </td><td> </td><td>one</td><td>two</td><td>three</td>" + "</tr><tr><td><a>Update</a> <a>Cancel</a></td><td><input name type=\"submit\" value=\"Refresh\" /> " + "<input name value=\"Abbrechen\" type=\"submit\" /></td>" + "<td><input name=\"_ctl2:_ctl0\" type=\"text\" value=\"1\" /></td>" + "<td><input name=\"_ctl2:_ctl1\" type=\"text\" value=\"2\" /></td>" + "<td><input name=\"_ctl2:_ctl2\" type=\"text\" value=\"3\" /></td>" + "</tr><tr><td> </td><td> </td><td> </td><td> </td><td> </td>" + "</tr></table>", markup, "I2"); }
public void Deny_Unrestricted() { DataGridTest unit = new DataGridTest(); unit.Defaults(); unit.TagName(); unit.CleanProperties(); unit.ViewState(); unit.SelectIndexOutOfRange(); unit.ControlStyle(); unit.Styles(); unit.Events(); unit.BubbleEvent(); unit.BubblePageCommand(); unit.SaveViewState(); unit.CreateColumnSet(); unit.CreateColumnsBinding(); unit.CreateSimpleColumns(); unit.CreateControls(); unit.CreationEvents(); unit.InitializePager(); unit.Render(); }
public void InitializeEditCell() { #if NET_4_0 string origHtml = "<table><tr><td> </td><td> </td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Update</a> <a>Cancel</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Refresh\" /> <input name=\"sucker$ctl02$ctl01\" type=\"submit\" value=\"Abbrechen\" /></td><td><input name=\"sucker$ctl02$ctl02\" type=\"text\" value=\"1\" /></td><td><input name=\"sucker$ctl02$ctl03\" type=\"text\" value=\"2\" /></td><td><input name=\"sucker$ctl02$ctl04\" type=\"text\" value=\"3\" /></td></tr><tr><td> </td><td> </td><td> </td><td> </td><td> </td></tr></table>"; #else string origHtml = "<table border=\"0\"><tr><td> </td><td> </td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Update</a> <a>Cancel</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Refresh\" /> <input name=\"sucker$ctl02$ctl01\" type=\"submit\" value=\"Abbrechen\" /></td><td><input name=\"sucker$ctl02$ctl02\" type=\"text\" value=\"1\" /></td><td><input name=\"sucker$ctl02$ctl03\" type=\"text\" value=\"2\" /></td><td><input name=\"sucker$ctl02$ctl04\" type=\"text\" value=\"3\" /></td></tr><tr><td> </td><td> </td><td> </td><td> </td><td> </td></tr></table>"; #endif DataGridTest p = new DataGridTest(); DataTable table = new DataTable(); EditCommandColumn e; string markup; e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.LinkButton; e.CancelText = "Cancel"; e.EditText = "Edit"; e.UpdateText = "Update"; table.Columns.Add(new DataColumn("one", typeof(string))); table.Columns.Add(new DataColumn("two", typeof(string))); table.Columns.Add(new DataColumn("three", typeof(string))); table.Rows.Add(new object [] { "1", "2", "3" }); p.DataSource = new DataView(table); p.Columns.Add(e); e = new EditCommandColumn(); e.ButtonType = ButtonColumnType.PushButton; e.CancelText = "Abbrechen"; e.EditText = "Bearbeiten"; e.UpdateText = "Refresh"; p.Columns.Add(e); // Force the ListItemType to be EditItem so we can test rendering the UpdateText/CancelText render p.EditItemIndex = 0; // This will trigger EditCommandColumn.InitializeCell p.CreateControls(true); p.ID = "sucker"; StringBuilder sb = new StringBuilder(); GetHierarchy(p.Controls, 0, sb); string h = sb.ToString(); int x = h.IndexOf(".TextBox"); // These are from the BoundColumns Assert.IsTrue(x != -1, "textbox1"); x = h.IndexOf(".TextBox", x + 1); Assert.IsTrue(x != -1, "textbox2"); x = h.IndexOf(".TextBox", x + 1); Assert.IsTrue(x != -1, "textbox3"); x = h.IndexOf(".TextBox", x + 1); Assert.IsTrue(x == -1, "textbox-end"); markup = ControlMarkup(p.Controls[0]); markup = markup.Replace("\t", ""); markup = markup.Replace("\r", ""); markup = markup.Replace("\n", ""); //Console.WriteLine("Markup:>{0}<", markup); Assert.AreEqual(2, p.Columns.Count, "I1"); HtmlDiff.AssertAreEqual(origHtml, markup, "I2"); }