This is a migrated thread and some comments may be shown as answers.

Get the client id using javascript in user control i.i ascx

3 Answers 440 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Qaja Mohiddin
Top achievements
Rank 1
Qaja Mohiddin asked on 12 Jun 2009, 04:52 PM
Hi
I am have a combo with a treeview in it, i need to find the selected node and i am able to do this in aspx page, but the same function fails in .ascx page.
The below is the function which i am calling in client side.

function

 

radPricingLevelTree_ClientNodeClicked(sender, eventArgs)

 

{

 

var node = eventArgs.get_node();

 

 

var comboBox = $find("<%= radPricingLevelCombo.ClientID %>");

 

 

comboBox.set_text(node.get_text());

comboBox.trackChanges();

comboBox.get_items().getItem(0).set_value(node.get_text());

comboBox.commitChanges();

comboBox.hideDropDown();

}
Pls help

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 15 Jun 2009, 08:20 AM
Hi Qaja Mohiddin,

You need to find the proper id of the combobox like this:

function radPricingLevelTree_ClientNodeClicked(sender, eventArgs) 
   ... 
   var comboID = sender.get_id().replace("_i0_radPricingLevelTree"""); 
   var comboBox = $find(comboID); 
   .... 


Best wishes,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Greg
Top achievements
Rank 1
answered on 02 Feb 2011, 06:20 PM
I am doing the same, but in a different manner.

I am using the radsplitter expand/collapse.

The problem is in one Radpane the radgrid is fixed & paged so when we collpase the bottom RadPane there is a void.
I want to change the attributes of the radGrid to show more rows to fill in the void as well as return it back when the splitter is expanded halfway up the page.

I'm using the collapse/expand event of the radpane to trigger the function that will change the events.
Right now the only thing I get is [object].  if I add tagname to it is says "Div"

This is while using <%=control.clientid=>  which I will include here.

The example above is okay if the sender is what you are looking for, but I'm looking for a different control where we would normally use getelementid().


Thanks


This is the test code for me to bring back the id of the control.


<

 

script language="javascript" type="text/javascript">
    function RadPaneCollapsed() {
        var dnetGrid;dnetGrid = document.getElementById('<%=grdcontrol.ClientID%>');
        if (dnetGrid != null) {
        alert(dnetGrid.tagName);
    }
    else {
        alert(
"No ID");
    }
}
</script>

 

0
Rachana
Top achievements
Rank 1
answered on 17 May 2012, 07:42 AM
my java script function is below am calling this function in "OnClientSelectedIndexChanging" event in rad combobox ...how to get client id instead of <%= %>,if i'll get id like below it was showing the error in the master page  i.e  The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) 
note: i am using  related combobox's,mainly am using this concept is to avoid post backs.. refer the following link
 demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx
1.I have 4 combobox's.... "OnClientSelectedIndexChanging"  event of 1st combobox  am calling the below function and getting the second combobox client ID
2.if no data exist in the dataset to bind to the 2nd combo box .how to display for 2nd, 3rd and 4th combobox there is  no data exists.
if i use object.clearItems(); or clear selection(); it is showing null exception
 
function LoadInstitutionList(sender, eventArgs) {
               var item = eventArgs.get_item();
               var CboTerm = $find("<%= RadCbocountry.ClientID %>");
               CboTerm.set_text("loading.........");
               if (item.get_index() >= 0) {
                   CboTerm.requestItems(item.get_value(), false);
               }
               else {
                   CboTerm.set_text(" ");
                   CboTerm.clearItems();
               }
           }
Tags
TreeView
Asked by
Qaja Mohiddin
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Greg
Top achievements
Rank 1
Rachana
Top achievements
Rank 1
Share this question
or