博客
关于我
强烈建议你试试无所不能的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        }
你可能感兴趣的文章
matlab GUI之 -- 绘图
查看>>
'scope' is defined but never used
查看>>
C++ 常量指针与指针常量
查看>>
VB下对HTML元素的操作
查看>>
四、MyBatis框架介绍及使用
查看>>
java如何追加写入txt文件
查看>>
【PHP框架CodeIgniter学习】使用辅助函数—建立自己的JSONHelper
查看>>
解决kernel headers报错
查看>>
正向代理与反向代理的区别【Nginx读书笔记】(zz)
查看>>
第二周作业WordCount
查看>>
web测试
查看>>
谈谈C#的继承机制(“子承父业”)
查看>>
分类算法总结
查看>>
随笔-20131209
查看>>
javascript内部原理篇[__proto__和prototype]
查看>>
shell脚本中获取本机ip地址的方法
查看>>
php内网探测脚本&简单代理访问
查看>>
解决克隆 centos虚拟机后修改克隆后的机器的ip、mac、uuid失败的问题
查看>>
android margin--负的margin的使用
查看>>
20162329张旭升 实验一:实验报告
查看>>