C# asp.net中的预渲染事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/722013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pre render event in asp.net
提问by peter
protected void rgStateTax_PreRender( object sender, EventArgs e )
{
if( rgStateTax.MasterTableView.IsItemInserted )
{
foreach( GridItem item in rgStateTax.Items )
{
item.Visible = false;
}
}
if( rgStateTax.EditItems.Count > 0 )
{
foreach( GridDataItem item in rgStateTax.Items )
{
if( item != rgStateTax.EditItems[0] )
{
item.Visible = false;
}
}
}
}
Here, rgStateTax is a Rad grid control. Is there any reason for marking the items as invisible? PreRender is the event before the page is actually displayed on the screen, right?.
这里,rgStateTax 是一个 Rad 网格控件。是否有任何理由将项目标记为不可见?PreRender 是页面实际显示在屏幕上之前的事件,对吗?
采纳答案by Joshua Shannon
PreRender is the event that takes place just before the HTML for a given control/page is generated (to later be sent to the browser). So by setting an item.Visible = false here it will not be rendered to the HTML (however it's ViewState will).
PreRender 是在给定控件/页面的 HTML 生成(稍后发送到浏览器)之前发生的事件。因此,通过在此处设置 item.Visible = false 它将不会呈现到 HTML(但是它的 ViewState 会)。
In this case it looks like the code is hiding all rows in the RadGrid when a user is editing/inserting an item I presume for less distractions for the end user.
在这种情况下,当用户编辑/插入一个项目时,代码似乎隐藏了 RadGrid 中的所有行,我认为是为了减少对最终用户的干扰。