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

[Solved] SelectedValue of radComboBox

2 Answers 149 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joseph Ambattu
Top achievements
Rank 1
Joseph Ambattu asked on 18 Jan 2010, 04:30 AM
Hi,
       I am using the following code to get the selectedValue of radComboBox in javascript to pass values to the parent page:

<script language="javascript" type="text/javascript">

        function passValues() {
            var combo = $find("<%= cmbBranch.ClientID %>");
            var comboValue = document.getElementById(combo.UniqueID + "_value").value;
            window.opener.document.getElementById('txtFindBrid').innerText = comboValue;
           }
 
    </script>
 I have placed the above code inside <head> </head> tag.  When I run the project I get the following error:
Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).  Please help me by giving a solution.

Joseph

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Jan 2010, 09:04 AM
Hi Joseph,

This error ca happen when there is a script block in the 'head' tag. To solve the problem, you should remove the script block from the head tags and put it somewhere else (e.g. put it in the body).

Otherwise could you please try to wrap your JavaScript code (no matter whether it is in the head section or not) in RadCodeBlock and see whether that make any difference?
RadCodeBlock and RadScriptBlock

And then try the following client side code in order to get the selected value from combobox.
Client side code:
 
    function getValue() { 
        var combo = $find('<%=cmbBranch.ClientID%>'); 
        alert(combo.get_value()); 
        alert(combo.get_text()); 
    } 

-Shinu.
0
Joseph Ambattu
Top achievements
Rank 1
answered on 18 Jan 2010, 11:06 AM
Hi Shinu,
   I have put my javascript in the RadCodeBlock tag inside the <head> tag as you suggested  and that has solved my problem.  Thank you very much.

Joseph
Tags
ComboBox
Asked by
Joseph Ambattu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Joseph Ambattu
Top achievements
Rank 1
Share this question
or