博客
关于我
强烈建议你试试无所不能的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        }
你可能感兴趣的文章
批处理中的call与start的个人学习心得
查看>>
BGP反射(RR)
查看>>
×××运算取ceiling
查看>>
搜索引擎的前世今生
查看>>
JSP
查看>>
经典排序算法 - 地精排序Gnome Sort
查看>>
mysql rand函数
查看>>
24种编程语言的Hello World程序
查看>>
Java中main函数参数String args[] 和 String[] args 区别
查看>>
Jarvis Oj Pwn 学习笔记-Tell Me Something
查看>>
【WP7进阶】——XNA游戏精灵的动画
查看>>
cat echo 输入多行文字至文本中
查看>>
puppet FAQ
查看>>
linux 基础命令(1)
查看>>
MySQL学习足迹记录01--SOURCE,SHOW
查看>>
DataInputStream与DataOutputStream的简单使用
查看>>
sql根据某一字段查询不重复记录,同时要查询出所有满足条件的字段信息
查看>>
RBL 列表查询网址
查看>>
nagios的错误及解决方法
查看>>
使用PIPESTATUS获取管道中所有命令的返回码
查看>>