博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
递归控件以加入JS方法
阅读量:6821 次
发布时间:2019-06-26

本文共 2763 字,大约阅读时间需要 9 分钟。

看到dudu关于递归控件的方法,想起以前实现过的递归控件以加入JS来将用户的动作写入日志:
None.gif
        
private
 
void
 SetCtlClentProperty(String sSecID,Control ctrl)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif
{
InBlock.gif            
if(ctrl!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
foreach (Control obj in ctrl.Controls)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
if (obj.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
InBlock.gif                        ((TextBox)obj).Attributes[
"onchange"]    +=    "SetPageDataStatus();SetCtrlStatus('"+sSecID+"');";
InBlock.gif
InBlock.gif                    
if (obj.GetType().ToString() == "System.Web.UI.WebControls.Label")
InBlock.gif                        ((Label)obj).Attributes[
"onchange"]    +=    "SetPageDataStatus();SetCtrlStatus('"+sSecID+"');";
InBlock.gif
InBlock.gif                    
if (obj.GetType().ToString() == "System.Web.UI.WebControls.DropDownList" && ((DropDownList)obj).AutoPostBack==false)
InBlock.gif                        ((DropDownList)obj).Attributes[
"onchange"]    +=    "SetPageDataStatus();SetCtrlStatus('"+sSecID+"');";
InBlock.gif
InBlock.gif                    
InBlock.gif                    
if (obj.GetType().ToString() == "System.Web.UI.WebControls.DropDownList" && ((DropDownList)obj).AutoPostBack==true)
InBlock.gif                        ((DropDownList)obj).Attributes[
"onchange"]    +=    "SetPageDataStatus();SetCtrlStatus('"+sSecID+"');__doPostBack('"+((DropDownList)obj).ClientID+"','');";
InBlock.gif                    
InBlock.gif                     
InBlock.gif                    
if ((obj.GetType().ToString() == "System.Web.UI.WebControls.CheckBoxList" || obj.GetType().ToString() == "System.Web.UI.WebControls.RadioButtonList" ) &&  ((CheckBoxList)obj).AutoPostBack==true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
for(int k=0;k<((CheckBoxList)obj).Controls.Count;k++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            ((CheckBox)((CheckBoxList)obj).Controls[
0]).Attributes["onclick"]    +=    "SetPageDataStatus();SetCtrlStatus('"+sSecID+"');__doPostBack('"+((CheckBox)((CheckBoxList)obj).Controls[0]).ClientID+"','');";
ExpandedSubBlockEnd.gif                        }
ExpandedSubBlockEnd.gif                    }
InBlock.gif                    
InBlock.gif                    
if((obj.GetType().ToString() == "System.Web.UI.WebControls.CheckBoxList" || obj.GetType().ToString() == "System.Web.UI.WebControls.RadioButtonList" )  && ((CheckBoxList)obj).AutoPostBack==false)
InBlock.gif                        ((CheckBox)((CheckBoxList)obj).Controls[
0]).Attributes["onclick"]    +=    "SetPageDataStatus();SetCtrlStatus('"+sSecID+"');";
InBlock.gif                    
InBlock.gif                    SetCtlClentProperty(sSecID,obj);
ExpandedSubBlockEnd.gif                }
ExpandedSubBlockEnd.gif            }
ExpandedBlockEnd.gif        }
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
/**/
/// <summary>
InBlock.gif        
/// Set Control's onchange event;
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="oPage">Page object</param>
ExpandedBlockEnd.gif        
/// <param name="sCtrlIDs">section ids seperated with ",", like "section1,section2,section3"</param>
None.gif
        
private
 
void
 SetCtlClentProperty(ArrayList oCtrlIDs)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif
{
InBlock.gif            
foreach (Control oSecID in oCtrlIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (oSecID == nullcontinue;
InBlock.gif                
if (this._ThisPage.IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
this._ThisPage.RegisterHiddenField(oSecID.ID,System.Web.HttpContext.Current.Request.Form[oSecID.ID]);
ExpandedSubBlockEnd.gif                }
InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
this._ThisPage.RegisterHiddenField(oSecID.ID,"unchanged");
ExpandedSubBlockEnd.gif                }
InBlock.gif                SetCtlClentProperty(oSecID.ID,oSecID);
ExpandedSubBlockEnd.gif            }
ExpandedBlockEnd.gif        }
None.gif        
private
 
void
 SetCtlClentProperty(ArrayList oCtrlIDs,
bool
 ClearState)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif
{
InBlock.gif            
foreach (Control oSecID in oCtrlIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (oSecID == nullcontinue;
InBlock.gif                
if (this._ThisPage.IsPostBack && !ClearState)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
this._ThisPage.RegisterHiddenField(oSecID.ID,System.Web.HttpContext.Current.Request.Form[oSecID.ID]);
ExpandedSubBlockEnd.gif                }
InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
this._ThisPage.RegisterHiddenField(oSecID.ID,"unchanged");
ExpandedSubBlockEnd.gif                }
InBlock.gif                SetCtlClentProperty(oSecID.ID,oSecID);
ExpandedSubBlockEnd.gif            }
ExpandedBlockEnd.gif        }
你可能感兴趣的文章
CISCO CEF技术浅析
查看>>
API调用的几种类型
查看>>
写在前面2
查看>>
我的友情链接
查看>>
Juniper防火墙中文件安装配置手册
查看>>
react-router 学习笔记
查看>>
tomcat安装配置
查看>>
Struts2.0+Hibernate2.5+Spring3.0搭建JavaEE项目要用的jar
查看>>
Lync Server 2010调整用户设置时,报“访问特权不够”错误解决方法
查看>>
2013互联网公司,年终奖有几何?
查看>>
Linux上安装二进制文件MySQL详解
查看>>
互联网
查看>>
MySQL load data 权限相关
查看>>
网站静态化处理—web前端优化—上(11)
查看>>
在sql server中建存储过程,如果需要参数是一个可变集合怎么处理?
查看>>
Junit4单元测试的基本用法
查看>>
centos6.5 安装jdk8
查看>>
dojo学习(一)入门
查看>>
PDO绑定含IN的SQL语句的参数注意事项
查看>>
3 - laravel 基础 - 中间件
查看>>