[正则表达式]前台JS得到控件ID (该控件被其它控件包住了)

GridView包GridView包TextBox, 得到TextBox的客户端ID的自动生成的部分:
^.*?\d+_[^_]+_[^_]+_[^_]+_+[a-z]+\d+_
匹配 GridSegment_ctl02_PP_ProcessTask_GridTask_ctl02_XXXXXXXX

Repeater包GridView包TextBox:
^.*?\d+_[^_]+_+[a-z]+\d+_
匹配 RepeaterPriceMaintain_ctl08_QDataGridPriceDetailMaintain_ctl02_XXXXXXXXXX

JS中的用法:
function GetValueFromQLookUp(obj, control, value)
            {      
                
var matchInfo = /^.*?\d+_[^_]+_+[a-z]+\d+_/;
                
var matchObjID =  obj.match(matchInfo);      
                
var halfClientID = matchObjID[0]  
                
var newID = halfClientID + control           
                document.getElementById(newID).value 
= value;   
            }

posted on 2008-03-05 16:02  Sammy  阅读(685)  评论(0编辑  收藏  举报

导航