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

javascript unable to find control inside usercontrol edit form

5 Answers 463 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vinh
Top achievements
Rank 1
Vinh asked on 26 Oct 2010, 05:22 PM

Hi,

I'm currently using the usercontrl edit form and I would like to have this function in javascript
if the value of the rdbBillable= 1
then enable some of the textboxes
else
disable the text boxes

The problem is when I place the javascript inside the ascx page, the it complaints that there is no javascript (Microsoft JScript runtime error: Object expected), but then if I put in the aspx page, it also complaint for this line

 

radio = $find(

'<%= rdbBillable.ClientID %>');

 

 

Compiler Error Message: CS0103: The name 'rdbBillable' does not exist in the current context.

Thanks

Vinh Vu 

5 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 28 Oct 2010, 08:17 AM
Hi Vinh,

Try putting this javascript in your user control and wrap it in a RadScriptBlock. Note that radio button with ID rdbBillable must be visible in the user control, i.e. it should not be inside another NamingContainer in the user control.

Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vinh
Top achievements
Rank 1
answered on 28 Oct 2010, 02:15 PM
I tried that too but still able to.  Do you have a sample that you can read a control from the user control edit form for the RadGrid?

Thanks

Vinh
0
Veli
Telerik team
answered on 28 Oct 2010, 02:56 PM
Hi Vinh,

Sure, I have attached a test page with a user control. The user control demonstrates 2 scenarios:

1. Getting a client component by its ClientID rendered with an inline expression (of the form <%= %>)
2. Getting a client component by its server id using $telerik.findControl()

Greetings,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Abdul
Top achievements
Rank 1
answered on 29 Nov 2010, 10:52 AM
Hello,
Following Error
Microsoft JScript runtime error: Object expected

Regards
Abdul Shaquoor
0
Princy
Top achievements
Rank 2
answered on 30 Nov 2010, 10:27 AM
Hello Abdul,

Check whether you have used same name when calling the client side event and in the client event handler.

ASCX:
<telerik:RadTextBox ID="RadTextBox1" runat="server" Width="200px">
</telerik:RadTextBox>
<input type="button" value="get this textbox from its client ID" onclick="getWithServerID(this)" />

Java script:
<script type="text/javascript">
    function getWithServerID(button) {
        var container = button.parentNode;
        var textBox = $telerik.findControl(container, "RadTextBox1");
        textBox.set_value("ClientID: " + textBox.get_element().id);
    }
</script>

Thanks,
Princy.
Tags
Grid
Asked by
Vinh
Top achievements
Rank 1
Answers by
Veli
Telerik team
Vinh
Top achievements
Rank 1
Abdul
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or