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

Cannot read property 'style' of null

1 Answer 328 Views
Window
This is a migrated thread and some comments may be shown as answers.
JP
Top achievements
Rank 1
JP asked on 19 Jul 2012, 03:38 PM
Hi,

I'm adding a RadWindow in the page's init event so I can use it to display async postback errors. But when I try to open the RadWindow on the client, I get the following javascript error:
"Cannot read property 'style' of null" in this codeblock: 
if(this._dockMode){this._contentElement.style.width="1px";

Thats my server-side code:

RadWindow window = new RadWindow();
 window.ID = "AsyncErrorMessageWindow";
 window.ClientIDMode = ClientIDMode.Static;
 HtmlGenericControl contentDiv = new HtmlGenericControl("div");
 contentDiv.ID = "AsyncErrorMessageWindowContent";
 contentDiv.Attributes["class"] = "AsyncErrorMessageWindow_Content";
 window.ContentContainer.Controls.Add(contentDiv);
 Form.Controls.Add(window);
and this is what I do client-side:

function onEndRequest(sender, args) {
   // error handler
   if (args.get_error()) {
      var message = args.get_error().message;
      args.set_errorHandled(true);
      if (args.get_error().name === 'Sys.WebForms.PageRequestManagerServerErrorException') {
         if (args._error.httpStatusCode == 0) {
            return false;
         }
      }
 
      var window = $find('AsyncErrorMessageWindow');
      var windowContent = $('.AsyncErrorMessageWindow_Content');
      windowContent.text(message);
      window.set_modal(true);
      window.set_title(ae_data.title);
      window.autoSize();
      window.show();
   }
    
   return true;
}

Is there something I forgot? I'm using the RadWindow at other locations where it works fine.

Thanks for your help!

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 23 Jul 2012, 12:39 PM
Hello JP,

I advise that your remove the following line:
window.ClientIDMode = ClientIDMode.Static;

because the RadControls for ASP.NET AJAX do not support this mode (Static). Many of them are complex container structures and need the standard ID generation mechanism ASP provides and this is also the case with the RadWindow.

Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
JP
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or