本文整理汇总了C#中WebGrid.Grid.RaisePostBackEvent方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.RaisePostBackEvent方法的具体用法?C# Grid.RaisePostBackEvent怎么用?C# Grid.RaisePostBackEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGrid.Grid
的用法示例。
在下文中一共展示了Grid.RaisePostBackEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GridRowBoundAllowEditInRow
public void GridRowBoundAllowEditInRow()
{
//Update The record set, we are updating record set 11
SqlConnectionUpdate();
Grid grid = new Grid();
SetupTestGrid(grid);
grid.PageSize = 100;
grid.Culture = new System.Globalization.CultureInfo("en-US");
grid.RowHighLight = System.Drawing.Color.Azure;
((WebGrid.DateTime)grid["dtmDate"]).Format = dateformat;
grid.RaisePostBackEvent("RecordCancelClick!");
grid.GridRowBound += grid_GridRowBound;
grid["intTest"].AllowEditInGrid = true;
grid["decTest"].AllowEditInGrid = true;
grid["dtmDate"].AllowEditInGrid = true;
grid["vchtest"].AllowEditInGrid = true;
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
Assert.Greater(grid.MasterTable.Rows.Count, 1);
// These are triggers from html being rendered.
string[] triggerStrings = new[]
{
"wggrid_40_vchTest",
"wggrid_40_decTest",
"wggrid_40_intTest",
"wggrid_40_dtmDate",
// "wggrid_40_dtmDate_trigger",
"cb_wggrid_40_bitFlag",
"wggrid_40_bitFlag",
"onmouseover=\"wgrowhighlight",
// "calendar.gif",
"wggrid_11_vchTest",
"wggrid_11_decTest",
"wggrid_11_intTest",
"wggrid_11_dtmDate",
// "wggrid_11_dtmDate_trigger",
"cb_wggrid_11_bitFlag",
"wggrid_11_bitFlag",
//DateTime column with today's DateTime
"value=\""+DateTime.Now.ToString(dateformat)+"\" id=\"wggrid_11_dtmDate\"",
//Test column with 'blah'+ DateTime
// "maxlength=\"50\" value=\"blah" +DateTime.Now.ToString(dateformat)+"\" id=\"wggrid_11_vchTest\"",
//Decimal column with value 5634 formatted default "N2"
"style=\"text-align: Right;\" value=\"5,634.00\" id=\"wggrid_11_decTest\"",
//Number column with 33345 formatted default with "N0"
"style=\"text-align: Right;\" value=\"33,345\" id=\"wggrid_11_intTest\""
};
string content = sb.ToString();
foreach (string part in triggerStrings)
{
int res = content.IndexOf(part);
Assert.Greater(res, -1,part+Environment.NewLine+content);
}
}
示例2: GridRowBound
public void GridRowBound()
{
Grid grid = new Grid();
SetupTestGrid(grid);
grid.RaisePostBackEvent("RecordCancelClick!");
grid.GridRowBound += grid_GridRowBound;
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
Assert.Greater(grid.MasterTable.Rows.Count, 1);
}
示例3: CreateAndDeleteRecord
public void CreateAndDeleteRecord()
{
CreateRecordSelect();
int CategoryId = GetCategoryId();
Grid grid = new Grid();
Testpage.Controls.Add(grid);
SetDataSource(grid);
grid.ID = "test";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.Standard;
grid.Width = Unit.Pixel(1000);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
Assert.AreEqual(grid.MasterTable.DataSourceType, DataSourceControlType.AccessDataSource);
int records = grid.MasterTable.Rows.Count;
grid = new Grid();
Testpage.Controls.Add(grid);
SetDataSource(grid);
grid.ID = "test";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.Standard;
grid.Width = Unit.Pixel(1000);
grid.RaisePostBackEvent(string.Format("RecordDeleteClick!{0}", CategoryId));
sb = new StringBuilder();
sw = new StringWriter(sb);
gridwriter = new HtmlTextWriter(sw);
////grid.ReLoadData = true;
grid.RenderControl(gridwriter);
// Assert.AreEqual(grid.MasterTable.Rows.Count, GetCategoryCount());
// Assert.AreEqual(records-1, grid.MasterTable.Rows.Count);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
Assert.LessOrEqual(grid.SystemMessage.Count, 1);
}
示例4: CreateAndDeleteRecord
public void CreateAndDeleteRecord()
{
CreateRecord();
string CategoryId =
Query.ExecuteScalar("SELECT TOP 1 CategoryID FROM Categories ORDER BY CategoryID DESC",
ConnectionAccessOleDb).ToString();
Grid grid = new Grid();
grid.DataSourceId = "Categories";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
int records = grid.MasterTable.Rows.Count;
grid = new Grid();
grid.DataSourceId = "Categories";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
grid.RaisePostBackEvent("RecordDeleteClick!" + CategoryId);
sb = new StringBuilder();
sw = new StringWriter(sb);
gridwriter = new HtmlTextWriter(sw);
grid.MasterTable.GetData(true);
grid.RenderControl(gridwriter);
// Assert.Less(grid.MasterTable.Rows.Count, records);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
}
示例5: AllowEditInGrid
public void AllowEditInGrid()
{
Grid grid = new Grid();
SetupGrid(grid);
grid["CategoryName"].AllowEditInGrid = true;
grid["Description"].AllowEditInGrid = true;
grid["CategoryId"].AllowEditInGrid = true;
grid["CategoryId"].Visibility = Visibility.Both;
Assert.AreEqual(grid.Mode, Mode.Edit);
grid.RaisePostBackEvent("RecordCancelClick!");
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
Assert.AreEqual(grid.Mode, Mode.Grid);
Assert.LessOrEqual(grid.SystemMessage.Count, 1);
Assert.Greater(grid.Rows.Count, 1);
}
示例6: CreateNewCategory
private Grid CreateNewCategory(Grid grid)
{
grid.DataSourceId = "Categories";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
grid.RaisePostBackEvent("NewRecordClick!");
grid.MasterTable.Rows[0]["CategoryName"].Value = "Category name";
grid.MasterTable.Rows[0]["Description"].Value = string.Format("Unique ID:{0}", DateTime.Now.Ticks);
return grid;
}
示例7: UpdateRecord
public void UpdateRecord()
{
Grid grid = new Grid();
grid = CreateNewCategory(grid);
grid.EditIndex = "6";
int records = grid.MasterTable.Rows.Count;
Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
grid.RaisePostBackEvent("RecordUpdateClick!!False");
Assert.AreEqual(grid.SystemMessage.Count, 0);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
////grid.ReLoadData = true;
grid.RenderControl(gridwriter);
Assert.Greater(grid.MasterTable.Rows.Count, records);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
}
示例8: OrderBy
public void OrderBy()
{
Grid grid = new Grid();
grid.DataSourceId = "Categories";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
grid.RaisePostBackEvent("ColumnHeaderClick![Categories].[CategoryName]");
grid.RaisePostBackEvent("ColumnHeaderClick![Categories].[Description]");
grid.RaisePostBackEvent("ColumnHeaderClick![Categories].[CategoryName]");
grid.RaisePostBackEvent("ColumnHeaderClick![Categories].[CategoryName]");
Assert.Greater(grid.MasterTable.Rows.Count, 1);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
Assert.IsNotEmpty(grid.SortExpression);
}
示例9: NewRecordAndCancelRecord
public void NewRecordAndCancelRecord()
{
Grid grid = new Grid();
grid.DataSourceId = "Employees";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
Assert.Greater(grid.MasterTable.Rows.Count, 1);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
grid.RaisePostBackEvent("NewRecordClick!");
Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
Assert.AreEqual(grid.MasterTable.Rows.Count, 1);
grid.RaisePostBackEvent("RecordCancelClick!");
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
grid.MasterTable.GetData(false);
Assert.Greater(grid.MasterTable.Rows.Count, 1);
}
示例10: GridUpdateGridRowsClickEvent
public void GridUpdateGridRowsClickEvent()
{
Grid grid = new Grid();
grid.DataSourceId = "Categories";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.Standard;
grid.Width = Unit.Pixel(1000);
Assert.IsNull(grid.EditIndex);
grid.UpdateRowsClick += tmp_UpdateRowsClickEvents;
grid.BeforeUpdateInsert += tmp_BeforeUpdateInsertUpdateRow;
grid.RaisePostBackEvent("UpdateRowsClick!");
grid["CategoryName"].AllowEditInGrid = true;
grid["Description"].AllowEditInGrid = true;
grid["CategoryId"].AllowEditInGrid = true;
grid["CategoryId"].Visibility = Visibility.Both;
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
Assert.LessOrEqual(grid.SystemMessage.Count, 1);
Assert.Greater(grid.MasterTable.Rows.Count, 1);
Assert.AreEqual(grid.MasterTable.Rows.Count, updaterowseventscount);
// foreach (WebGrid.Row row in tmp.MasterTable.Rows)
// Console.WriteLine(row["Description"].Value);
Assert.IsTrue(updaterowsclickevents);
}
示例11: GridSearchEvents
public void GridSearchEvents()
{
Grid grid = new Grid();
grid.SearchChanged += grid_SearchChangedEvents;
CreateNewCategory(grid);
grid.Page = Testpage;
grid.Search = "DoesNotExist";
grid.RaisePostBackEvent("RecordCancelClick!");
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
////grid.ReLoadData = true;
grid.RenderControl(gridwriter);
grid.Dispose();
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
Assert.AreEqual(grid.MasterTable.Rows.Count, 0);
//Assert.IsTrue(searcheventrunnned);
// Is not triggered because HttpContext is missing during the test phase.
}
示例12: NewRecordWithDataSourceControl
//[Test]
public void NewRecordWithDataSourceControl()
{
Grid grid = new Grid();
Testpage.Controls.Add(grid);
SetDataSource(grid);
grid.ID = "test";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
Assert.Greater(grid.MasterTable.Rows.Count, 1);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
grid.RaisePostBackEvent("NewRecordClick!");
Assert.AreEqual(grid.MasterTable.Rows.Count, 1);
Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
}
示例13: SelectFromXmlDataSourceEditUpdate
public void SelectFromXmlDataSourceEditUpdate()
{
Grid grid = new Grid();
SetupGrid(grid);
XmlDataSource ds = new XmlDataSource();
ds.XPath = "//Language//*";
ds.ID = "test1";
ds.DataFile = Path + "\\WebGridMessages.xml";
Testpage.Controls.Add(ds);
grid.DataSourceId = ds.ID;
grid["LanguageID"].Primarykey = true;
grid.EditIndex = "Norwegian";
grid.DisplayView = DisplayView.Detail;
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
string text = "T:" + DateTime.Now.Ticks;
grid.Rows[0]["PagerPrefix"].Value = text;
grid.BeforeUpdateInsert += grid_BeforeUpdateInsert;
grid.RaisePostBackEvent("RecordUpdateClick!Norwegian!False");
grid.RenderControl(gridwriter);
Assert.Greater(grid.Rows.Count, 1, sb.ToString());
Assert.LessOrEqual(grid.SystemMessage.Count, 1);
string filecontent = System.IO.File.ReadAllText(Path + "\\WebGridMessages.xml");
Assert.Greater(filecontent.IndexOf(text), 0);
/* string[] triggerStrings = new[]
{
"Forrige side",
"RecordCancelClick!Norwegian!",
"RecordUpdateClick!Norwegian!False"
};
string content = sb.ToString();
foreach (string part in triggerStrings)
{
int res = content.IndexOf(part);
Assert.Greater(res, -1, part + Environment.NewLine + content);
}
*/
}
示例14: TextColumn
public void TextColumn()
{
Grid grid = new Grid();
Text column = new Text("column", grid.MasterTable);
column.Required = true;
column.Primarykey = true;
Text column2 = new Text("column2", grid.MasterTable);
column2.IsEmail = true;
Text column3 = new Text("column3", grid.MasterTable);
column3.IsEmail = true;
Text column4 = new Text("column4", grid.MasterTable);
column4.IsUrl = true;
column4.Required = true;
Text column5 = new Text("column5", grid.MasterTable);
column.IsPassword = true;
Text column6 = new Text("column6", grid.MasterTable);
Text column7 = new Text("column7", grid.MasterTable);
Text column8 = new Text("column8", grid.MasterTable);
grid.MasterTable.Columns.Add(column);
grid.MasterTable.Columns.Add(column2);
grid.MasterTable.Columns.Add(column3);
grid.MasterTable.Columns.Add(column4);
grid.MasterTable.Columns.Add(column5);
grid.MasterTable.Columns.Add(column6);
grid.MasterTable.Columns.Add(column7);
grid.MasterTable.Columns.Add(column8);
SetupGrid(grid);
// Not allowed content
grid.MasterTable.Rows[0]["column"].Value = "";
grid.MasterTable.Rows[0]["column4"].Value = "";
grid.MasterTable.Rows[0]["column3"].Value = "[email protected]";
// Allowed Content
grid.MasterTable.Rows[0]["column2"].Value = "[email protected]";
grid.MasterTable.Rows[0]["column5"].Value = "somepassword";
grid.MasterTable.Rows[0]["column6"].Value = "<validtext>";
grid.MasterTable.Rows[0]["column7"].Value = "<%valid text%>";
grid.MasterTable.Rows[0]["column8"].Value = "valid text";
Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
grid.RaisePostBackEvent("RecordUpdateClick!!False");
Assert.AreSame("", grid.MasterTable.Rows[0]["column"].Value.ToString());
Assert.AreSame("", grid.MasterTable.Rows[0]["column4"].Value.ToString());
Assert.AreSame("[email protected]", grid.MasterTable.Rows[0]["column3"].Value.ToString());
Assert.AreEqual(grid.SystemMessage.Count, 3);
}
示例15: SetupGrid
private void SetupGrid(Grid grid)
{
grid.ID = "wggrid";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
grid.RaisePostBackEvent("NewRecordClick!");
Testpage.Controls.Add(grid);
}