Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 08, 2010 07:33 AM by Zizhuoye Chen - MSFT
Member
5 Points
9 Posts
Jul 06, 2010 06:30 AM|LINK
I've got a basic web form page which I use 2 user controls on. The first control has the second nested within it...
On my first popup.ascx i have the following javascript validation
.ClientID %>');
txtDate works fine so is there some issue with having nested user controls and using getElementById I'm missing?
Thanks.
ASP.NET User controls javascriptript asp.net javascript and C# asp.net validation user control javascript
Jul 06, 2010 04:08 PM|LINK
Managed to get a reference to the nested drop down list by using the following function:
function GetClientId(strid) { var count=document.forms [ 0 ] . length ; var i = 0 ; var eleName; for (i = 0 ; i < count ; i++ ) { eleName = document.forms [ 0 ] . elements [ i ] .id; pos=eleName.indexOf ( strid ) ; if(pos >= 0) break; } return eleName; }
Kind of a work around I guess. Can anyone better this method of solving it?
All-Star
21915 Points
1915 Posts
Jul 08, 2010 07:33 AM|LINK
Hi,
i am not sure what cause this issue.
But you can try to use this code to find control in WebUserControl which nested in your aspx page.
Suppose the popup.ascx's ID is popupControl and the locations.ascx's ID is locationControl
To find "txtArrangedDate" which in popup.ascx we can use
And also to find "drpLocationList" which in location.ascx we can use var ddlLocation = document.getElementById('<%=popupControl.FindControl("locationControl").FindControl("drpLocationList").ClientID%>');
And also to find "drpLocationList" which in location.ascx we can use
Hope this can help you.
BarryFanta
Member
5 Points
9 Posts
nested user controls and javascript getElementById
Jul 06, 2010 06:30 AM|LINK
I've got a basic web form page which I use 2 user controls on. The first control has the second nested within it...
On my first popup.ascx i have the following javascript validation
txtDate works fine so is there some issue with having nested user controls and using getElementById I'm missing?
Thanks.
ASP.NET User controls javascriptript asp.net javascript and C# asp.net validation user control javascript
BarryFanta
Member
5 Points
9 Posts
Re: nested user controls and javascript getElementById
Jul 06, 2010 04:08 PM|LINK
Managed to get a reference to the nested drop down list by using the following function:
function GetClientId(strid)
{
var count=document.forms [ 0 ] . length ;
var i = 0 ;
var eleName;
for (i = 0 ; i < count ; i++ )
{
eleName = document.forms [ 0 ] . elements [ i ] .id;
pos=eleName.indexOf ( strid ) ;
if(pos >= 0) break;
}
return eleName;
}
Kind of a work around I guess. Can anyone better this method of solving it?
Zizhuoye Che...
All-Star
21915 Points
1915 Posts
Re: nested user controls and javascript getElementById
Jul 08, 2010 07:33 AM|LINK
Hi,
i am not sure what cause this issue.
But you can try to use this code to find control in WebUserControl which nested in your aspx page.
Suppose the popup.ascx's ID is popupControl and the locations.ascx's ID is locationControl
To find "txtArrangedDate" which in popup.ascx we can use
Hope this can help you.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework