.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Not able to access child controls in user control using javascript

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net


I have a user control "SettingsControl" containing an ajax:CollapsiblePanelExtender which in turn has a GridView (gridView) and checkBoxes. On top of GridView we have two LinkButtons "Select All" and "Clear All". I have written to enable select all and clear all functionality. Select All should select all the rows in the grid by calling the following JavaScript written on the Client .aspx file.

function SelectAll(chk)
    //get reference of GridView control
    var grid = document.getElementById('<%= SettingsControl1.FindControl("gridView").ClientID %>');
    //variable to contain the cell of the grid
    var cell;

    if (grid.rows.length > 0)
        //loop starts from 1. rows[0] points to the header.
        for (i=1; i<grid.rows.length; i++)
            //get the reference of first column
            cell = grid.rows[i].cells[0];


View Complete Post

More Related Resource Links

How to Access Parent Page (.aspx) control (IDs) from its child User Control (.ascx)

I have a parent .aspx page that has a asp:panel control in it, and this parent .aspx is also referencing a user control that I registered in that .aspx. Lets just call it usercontrolA.ascx for this post.The user control has a radiobuttonlist itself.Based on a selection from the radiotbuttonlist in the user control, I want to be able to hide the asp:panel in my .aspx (parent) but unfortunately I cant' get it to work:parentPanel.visible = true;  <<< I trried this in usercontrolA.ascx.csBut the user control doesn't know about the panel in the parent .aspxSo do I need to expose that somehow from the parent so that I can access it from the code behind of the child .ascx?  How?

Acessing controls in usercontrol in javascript function where user control hosted in webpart



1how to acess controls in usercontrol  in javascript function where user control hosted in webpart


2)How to retieve values from javscript code to server side

details as follows

StringBuilder controlString = new StringBuilder();
            controlString.Append("<p>" + CurrentPage.ToString() + "of " + TotalPages.ToString() + " </p>");
            for (int intIndex = 1; intIndex <= TotalPages; intIndex++)
                controlString.Append("<li><a hre

How to access child(.ascx) page control from parent page(.aspx) javascript


I have functionality to select All check boxes on grid rows.

Child User control is having grid with checkbox to select all rows of grid. I want to select individual cell html from each row when I select all rows when checkbox 'select all' is clicked and place it into textbox which is in Parent page.

This textbox can only be in parent page.

So i need to call child(.ascx) page control from parent page(.aspx) using javascript as follows.

function CheckUncheckChildren(event)
        var childChkBoxes = document.getElementById('<%=gvUserDetails.ClientID %>').getElementsByTagName("input");
        var childChkBoxCount = childChkBoxes.length;
        var evtelem = (isIE())?event.srcElement:event.currentTarget;
        if(evtelem.checked == true)
            for(var i = 0; i<childChkBoxCount; i++)

How to Access controls of Web User Control in a web Page using C#?


I Have a webpage named "Test.aspx" and a web user control named "TestWebContro.ascx",.. 

i have a "Linkbutton" on  "TestWebContro.ascx" and "Label" on "Test.aspx",.. now my query is how can we change the text value of "label" on the click event of "LinkButton",...

<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; background-color: White">
            <td style="width: 10px">

User Controls and Control Extenders


Two separate questions, but sufficiently intertwined that I'm going to try the two together....

Firstly - User Controls and Behaviours

I have a User Control which contains a few visual controls.  I am attaching some behaviours by using GetScriptDescriptors and am passing some JavaScript to the browser using GetScriptReferences.  That is all rock solid and working well.  However, when developing, I did discover that I couldn't attach the behaviours to the User Control itself - not surprising as rendering a User Control does not create a DOM element which represents the actual control.  So, I have attached my behaviours to a "random" TextBox within the User Control. 

So - first question, is there a better way to do that?  For example, should I always be rendering a SPAN as an element to surround the control?  Not sure what that would do to the robustness of the rendering.  What is the right way to attach a behaviour to a User Control.

Secondly - Accessing those same Behaviours later

Assume I have placed a User Control on the page.  That User Control exposes a Property (actually a Javascript Function of course) which does "something" to the control - for the sake of example we'll say that the function is set_Border(colour). 

Removing a (child) user control from an observable collection

Hey all, so I have an ObservableCollection of UserControls.  These user controls have their own xaml and each of these has some type of "Close" button so it would be removed from the ObservableCollection. A groupbox is binded to the ObservableCollection so it would show all the UserControls.  When a user clicks on the "Close" button, the user control is removed from the ObservableCollection and thus, the groupbox.  How can I do this?  I've tried something like   (this .Parent as ObservableCollection<asdf>).Remove(this );   where asdf is a UserControl but I get a bunch of compiler errors.

Access UserControl Control from a JavaScript Function

I have a requirement to launch a Modal Javascript dialog box from within my usercontrol,I have done this by <code> function browseControlAction(ProjID,ControlID) { strPrompt = 'Select a Previous control action..'; strOptions = 'dialogWidth:25;dialogHeight:30;status:no;resizable:yes'; selectedAction = window.showModalDialog('browseControlActions.aspx?ProjID=' + ProjID + '&Control=' + ControlID, strPrompt, strOptions); var sControl = ' + ControlID + '; if (selectedAction != null) { alert(ControlID.toString()); alert(selectedAction); var sTest = ControlID + '_txtControlAction'; alert(sTest); var sTest2 = 'txtSummary'; alert(sTest2); document.getElementById('txtCurrentControls').innerText=selectedAction;   //this works as this a control on the page itself document.getElementById(sTest2).innerText=selectedAction;      //Ditto document.getElementById(sTest).innerText=selectedAction;    //This Fails as this is the control in the USercontrol I am trying to Access //__doPostBack('',''); }</code>can anybody tell me why I can't access the Textbox control on the USercontrol?

How to access ServerSide control Value in Javascript changed by Ajax

Hello,I have a Textbox whose value is been changed using ServerSide code (AJAX based - Partial postback) and now I want to access that changed value in JavaScript. Please suggest me that how can I access that value.document.getElementByID is displaying old value.Things work fine with full postback but are creating above issue with Partial Postback.Thanks, in Advance....

Control User Access to Document Workspace

I have set up a document workspace section with several folders and files.  I have set up a group that has full control and set up a group with contribute.  Now I would like to set up several groups that will only have access to specific portions within the site for contribute.  I see where I can set up group overall, but have not seen where to narrow down to spefici folders/files for group to view.  Do I get to the specific folder or document and then set up access or do it from Home?   Any help is appreciated! Peter

Accordion control access in Javascript using Content page

Hi, I struggled with some javascript issues, and discovered that the problem seemes to come from a failed ajax control access.Here's my problem:I have a master page and a content page.In my content page, I have an accordion with 2 panes.1rst pane: a textbox and a validation button;                     I want the button to fire javascript function without reloading page (using "return false;");In my master page, I put my ToolkitScriptManager.In my content page, I put my script containing the functions.The problem is that it seems like I can't access the accordion control in my js functions, whereas I can access my textbox value...Here is my source:<%@ Page Language="C#" MasterPageFile="~/Default.master" Title="CLEOR RH | Home" CodeFile="Default.aspx.cs" Inherits="Default_aspx" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server"> <script type="text/javascript"> var step1 = false; function pageLoad() { var accCtrl = $find('AccordionCtrl_AccordionExtender');

embedded javascript in user control

Hello, I would like to know if it is possible to embed javascript in a user control. I've followed this article advices. It works with a custom server control but not with a web user control. Is there something special to do to make it work with user controls ?Moreover, it would be nice that only one javascript reference (<script src=""></script>) figure on the page if I use the same user control several times on the page. Is it possible ? Thanks, mathmax 

User Access Control

Hai, I am using VS2005 and SQL Server 2000 I have few small exe like duty_roster, Leave_mgt, Overtime etc. and Have a main exe named HRIS. Now I am calling these exe when run HRIS. there is a list of exe and when anyone click on the specific name then that exe open and he can work. Now I want to control on access. How can I create the dynamic access so that if I want anyone to give specific modules, menu, submenu, popmenu access then give it and later if i want i can off. I have little idea that there will be a user group with specific access. Now I create the usergroup but how can I set the access. Please help me how can I do this. It would better if u can give me link of same examples or code. please help me.please please

control the access of data based on user id

Hi, We have a cube (Insurance related project), users are grouped under a windows user group and they have their individual user id's . Now the question is how to restrict the users to view the data only related to them based on the user id(which is included in windows user-group)...?   if any mdx query is needed tell me that also

Access user control from another user control which is on the first user control


I have Control A and on Control A is control B.

From Control B i need to access and set the value of a label on Control A but I keep getting "Object not set to an instance of an object"

I have accessed controls before from other controls but this is the first time I have had to do it when the second control is actually ON the first control?

DataAnnotation on multiple user controls displaying on wrong control


I have a table that displays a user control on each row. The user controls are strongly typed to a viewmodel which contains DataAnnotation style validation. If one of the rows has invalid data entered (lets say the 3rd row) the data annotation validates display agains the first row/user control.

How do I get the data annotation to show against the relevant user control?

I'd post a pic to show what I mean except it will not display it!.:/

How to access label object in a user control


I thought I did something like the following inorder to find the labels in a user object but when I revisited it, it did not work.  Any ideas???




using System.Collections.Generic;







problem with user control+update panel+javascript


hai all,


Im having a aspx page which has 5 tabs inside a update panel..also I have a user control

Wen I click each tab im dynamically loading dat user control .

The problem is im using javascript in dat user control..

the user control has a button which displays a panel containing three grid views  n s activated by a java script as given below..

function Elig()



'<%=btnLegend.ClientID %>')).click(function(){


('<%=pBody.ClientID %>')).slideToggle('slow');




Wen i run the aspx page the first tab  successfully loaded with dat user control n a

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend