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 static void Validation_Load (Page p) { string testType = (string)WebTest.CurrentTest.UserData; DataGridTest dg = new DataGridTest (); dg.ID = "mygrid"; EditCommandColumn e; e = new EditCommandColumn (); e.ButtonType = ButtonColumnType.LinkButton; e.CancelText = "Cancel"; e.EditText = "Edit"; e.UpdateText = "Update"; switch (testType) { case "ValidatingValid": case "ValidatingInvalid": case "ValidationGroupIncluded": case "ValidationGroupNotIncluded": e.CausesValidation = true; break; case "NotValidatingInvalid": e.CausesValidation = false; break; } switch (testType) { case "ValidationGroupIncluded": case "ValidationGroupNotIncluded": e.ValidationGroup = "Group1"; break; default: e.ValidationGroup = ""; break; } dg.Columns.Add (e); TextBox tb = new TextBox (); tb.ID = "Text1"; switch (testType) { case "ValidatingValid": tb.Text = "111"; break; case "ValidatingInvalid": case "NotValidatingInvalid": case "ValidationGroupIncluded": case "ValidationGroupNotIncluded": tb.Text = ""; break; } RequiredFieldValidator v = new RequiredFieldValidator (); v.ControlToValidate = "Text1"; switch (testType) { case "ValidationGroupIncluded": v.ValidationGroup = "Group1"; break; case "ValidationGroupNotIncluded": v.ValidationGroup = "NotGroup1"; break; default: v.ValidationGroup = ""; break; } TemplateColumn tc = new TemplateColumn (); tc.EditItemTemplate = new ValidatingEditTemplate (tb, v); dg.Columns.Add (tc); ObjectDataSource ods = new ObjectDataSource ("MyObjectDS", "Select"); ods.UpdateMethod = "Update"; ods.DataObjectTypeName = "MyObjectDS"; ods.ID = "MyDS"; p.Form.Controls.Add (ods); dg.DataSource = ods; //dg.DataKeyField = "i"; //DataTable table = new DataTable (); //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" }); //dg.DataSource = new DataView (table); dg.EditItemIndex = 0; p.Form.Controls.Add (dg); dg.DataBind (); if (!p.IsPostBack) { WebTest.CurrentTest.UserData = dg.Items [0].Cells [0].Controls [0].UniqueID; } }
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 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"); }
public void ThisIsADGTest () { #if NET_4_0 string origHtml = "<table 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$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>"; #else string origHtml = "<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$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>"; #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); 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", ""); HtmlDiff.AssertAreEqual (origHtml, markup, "I2"); }
public void InitializeCell () { #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>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>"; #else string origHtml = "<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>"; #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); // 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", ""); HtmlDiff.AssertAreEqual (origHtml, markup, "I2"); //ShowControlsRecursive (p.Controls [0], 1); }