博客
关于我
强烈建议你试试无所不能的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        }
你可能感兴趣的文章
WinForm更新文件
查看>>
setprecision **fixed
查看>>
JVM系列五:JVM监测&工具[整理中]
查看>>
局部自适应自动色阶/对比度算法在图像增强上的应用。
查看>>
CMD命令
查看>>
Spring中@Autowired与@Resource的区别
查看>>
Python 学习笔记 -- 类和实例
查看>>
Android 静默安装/后台安装
查看>>
java 非空判断类
查看>>
【html5】如何让Canvas标签自适应设备
查看>>
SecureCRT最佳配色方法+直接修改默认配置方法 - imsoft.cnblogs
查看>>
通俗地介绍下---数据结构之堆
查看>>
JQuery实现简单的服务器轮询效果
查看>>
项目Alpha冲刺 1
查看>>
项目Alpha冲刺 10
查看>>
【转载】.NET中使用Redis
查看>>
Go 在游戏行业中的工程实践
查看>>
javascript 性能优化
查看>>
html禁止清除input文本输入缓存
查看>>
数据库MySQL 之 库操作
查看>>