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

RadWindow cannot be found in UpdatePanel

3 Answers 165 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 18 May 2011, 07:25 AM
Hi

I have a page on which is a complex multi tabbed form that I want to appear when the user clicks a link on the main page.

Simple stuff. This I had working with the form appearing in a div that was hidden and simply made visible. However, having bought the Rad controls for ASP.NET I wanted the use the very attractive RadWindow to hold the form. It is there the problems began.

The entire form is in an update panel as it needs to be for many reasons not relevant to this issue.

The top of the form looks like this.

<asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional">
    <ContentTemplate>  
        <telerik:RadWindowManager ID="rwManager" Behaviors="Close,Move, Resize" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" runat="server" Skin="Outlook" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="rwAdvancedSearchForm" Modal="true" runat="server" Width="700" Height="600"
                    <ContentTemplate>
                        <table class="dv" cellpadding="0" cellspacing="0" border="0">

and so no.

You can see in there the first (and only) RadWindow in this RadWindowManager is called rwAdvancedSearchForm.

Back on the page I have a link that calls this javascript function.

function showAdvancedSearchForm(){
    var win = $find("<%#rwAdvancedSearchForm.ClientID %>");
    win.show();
    win.center();
}
... where ASP.NET is putting the name of the control into the page.

The problem is that the javascript breaks on the line 'win.show() as 'win' is not found.

Looking at the source code I can see that asp.net has put the correct name into the page. Here is a bunch of code from the source that has the js function above and the div at the bottom that is rsAdvancedSearchForm. You can see the names are correct.

     
function showAdvancedSearchForm(){
    var win = $find("ctl00_PageContent_rwAdvancedSearchForm");
    win.show();
    win.center();
}
   
 
</script>

 
<div id="ctl00_PageContent_UpdatePanel1">
         
        <div id="ctl00_PageContent_rwManager" style="display:none;">
 
        <div id="ctl00_PageContent_rwAdvancedSearchForm" style="display:none;">

Despite this the javascript cannot 'show()' the div has it cannot be found.

What's going on?





3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 May 2011, 08:42 AM
Hello Brad,

The correct method of accessing RadControls using find method is "$find('<%=rwAdvancedSearchForm.ClientID%>')". This worked as expected at my end.

Javascript:
<script type="text/javascript">
function showAdvancedSearchForm()
{
          var win = $find('<%=rwAdvancedSearchForm.ClientID%>');
        win.show();
        win.center();
}
</script>

Thanks,
Princy.


0
Brad
Top achievements
Rank 1
answered on 19 May 2011, 12:06 AM
Princy

Thanks for your reply but alas that is not the solution.

You code does not work either.

After it failed I opened Firebug. If I take the 'find' code

$find('<%=rwAdvancedSearchForm.ClientID%>');

.... and put it in the Firebug console and run it, the result is NULL.

Same result if I put in my original find command

$find("<%#rwAdvancedSearchForm.ClientID %>");

The RadWindow cannot be found in the page.
.






0
Brad
Top achievements
Rank 1
answered on 20 May 2011, 06:43 AM
I fixed this in a round about 'but should have to code like this' sort of way.

First I changed the way the page was working. It needed to post back before reopening the RadWindow (which as annoyingly closing on post back).  It was on this attempt to reload the RadWindow I got exactly the same error.

I found that after the page was loaded, I could go into Firebug and call the showAdvancedSearchForm() method. And it worked.

This suggested to me that the first call was happening before the form was fully loaded. Hence, the RadWindow div could not be found.

To fix this took a few steps

First I put a javasecript variable on the page

var DoPopup = false;

Next in my ASP.NET page I changed my code that output the javascript from this

protected void ReloadPopup()
{
    string jScript;
    jScript = "showAdvancedSearchForm();";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", jScript, true);
}


To this.

protected void ReloadPopup()
{
    string jScript;
    jScript = "DoPopup = true;";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", jScript, true);
}

Finally, in my jQuery (document).ready function, I did this.

$(document).ready(function() {
 
   if (DoPopup) {
          showAdvancedSearchForm();
          DoPopup = false;
      }
 
  });

Done and dusted.

Tags
General Discussions
Asked by
Brad
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Brad
Top achievements
Rank 1
Share this question
or