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

RadColor picker object is null

1 Answer 57 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Mariyam Khambhati
Top achievements
Rank 1
Mariyam Khambhati asked on 12 Jan 2009, 03:16 PM
Hi,

I am able to obtain the RadcolorPicker object on in the following case:

serverside code(aspx.cs)

                protected void Page_Load(object sender, EventArgs e)
{
            dropdownList1.Attributes.Add("onchange", "javascript:clddIndicesList_onchange();");
                 }

Clientside code:(aspx)

         function clddIndicesList_onchange()
{
       radColorPicker.set_visible(true);
             
        }

but RadColorPicker object will be 'null' in the following cases
1) <body onload="clddIndicesList_onchange()">

2) End of the aspx page <script language="javascript" type="text/javascript">clddIndicesList_onchange();</script>

Please let me know the solution for this?

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 13 Jan 2009, 03:01 PM

Hi Mariyam,

The controls in the RadControls for ASP.NET AJAX suite are built upon the MS AJAX framework and the framework itself creates its controls (including RadColorPicker) in the Sys.Application.add_init() method.

Here is how the client events are fired in the page life cycle:

window.onload -> Sys.Application.init -> Sys.Application.load

You can see that the client object representation of MS AJAX controls are created just as the last code on the page in the Sys.Application.init event, which is raised after the window.onload event.

That is why when you call your code in window.onload by registering the client script, the RadColorPicker will still not be created on the page and you will get an error. To avoid this problem, you can either execute your code with a small timeout, or use the Sys.Application.add_load method.

Sincerely yours,

Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ColorPicker
Asked by
Mariyam Khambhati
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or