博客
关于我
强烈建议你试试无所不能的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        }
你可能感兴趣的文章
IOC的类型(DI注入)
查看>>
2015年度总结--android开发
查看>>
Linux - 修改内核启动顺序及删除无用内核
查看>>
kubernetes 健康检查和初始化容器
查看>>
es索引管理工具-curator
查看>>
Python+Django写一个本机性能监控应用?
查看>>
thinking in java
查看>>
Can not deserialize instance of java.lang.Integer out of START_ARRAY token
查看>>
矩阵按列按行归一化到L2范数的原理和最精简Matlab代码(转)
查看>>
如何方便的建立远程链接服务器
查看>>
Python自动化测试白羊座-week3文件操作
查看>>
centos安装jenkins
查看>>
JS合并两个数组的方法
查看>>
VBS将本地的Excel数据导入到SQL Server中
查看>>
ruby "==" "equal"
查看>>
JS 将数字转化成为货币格式
查看>>
cookie,session
查看>>
linux 定时任务
查看>>
iOS--动画--GitHub前50名的Objective-C动画相关库
查看>>
豆瓣电影
查看>>