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

Javascript Error closing RadWindow...

1 Answer 25 Views
Window
This is a migrated thread and some comments may be shown as answers.
mark baer
Top achievements
Rank 1
mark baer asked on 25 Apr 2011, 06:21 PM
I have an ASP.NET page that pops up a RadWindow with 3 small fields in it.  The user adds data, clicks save and once the data is saved, the window should close.  The Save is working, but if I try to say:

RadWindowManager1.Windows[0].Visible=False;

I get a javascript error:  Microsoft JScript runtime error: 'undefined' is null or not an object

I'm sure it's some type of timing issue with the postback/RadWindow, but I'm not sure how to fix it.  Below is my HTML for the RadWindow and a small portion of the code behind.

Thanks

mark

<telerik:RadWindowManager ID="RadWindowManager1" Behaviors="Close" 
runat="server"><BR>                                    
<Windows><BR>                                        
<telerik:RadWindow ID="radWinAddCredit" 
OpenerElementID="btnAddCreditForTalent" 
runat="server"<BR>                                            
Modal="true" AutoSize="true" Title="Add/Edit Credit" 
VisibleStatusbar="false"<BR>                                            
VisibleOnPageLoad="False" Skin="WebBlue" Height="300px" 
ShowContentDuringLoad="False"<BR>                                            
Width="375px" 
Behaviors="Close"><BR>                                            
<ContentTemplate><BR>                                                
<table class="form" 
width="100%"><BR>                                                    
<tr><BR>                                                        
<td class="formLabel-RightAlign" 
align="left"><BR>                                                            
Craft<BR>                                                        
</td><BR>                                                        
<td><BR>                                                            
<telerik:RadComboBox ID="cboCrafts" Skin="WebBlue" Width="205px" 
ZIndex="5000" 
MarkFirstMatch="true"<BR>                                                                
EmptyMessage="Type to Select..." 
runat="server"><BR>                                                            
</telerik:RadComboBox><BR>                                                            
<asp:RequiredFieldValidator ID="valCreditCrafts" 
ControlToValidate="cboCrafts" 
runat="server"<BR>                                                                
ErrorMessage="Required" InitialValue="Type to Select..." 
ValidationGroup="CreditGroup"></asp:RequiredFieldValidator><BR>                                                        
</td><BR>                                                    
</tr><BR>                                                    
<tr><BR>                                                        
<td 
class="formLabel-RightAlign"><BR>                                                            
Title<BR>                                                        
</td><BR>                                                        
<td><BR>                                                            
<telerik:RadComboBox ID="cboShowTitles" Skin="WebBlue" ZIndex="5000" 
Width="205px"<BR>                                                                
EnableAutomaticLoadOnDemand="true" EmptyMessage="Type to Search..." 
MarkFirstMatch="true"<BR>                                                                
runat="server" EnableLoadOnDemand="True" 
ItemsPerRequest="100"><BR>                                                                
<WebServiceSettings Method="GetShowTitles" 
Path="../Admin/Controls/AdminService.asmx" 
/><BR>                                                            
</telerik:RadComboBox><BR>                                                            
<asp:RequiredFieldValidator ID="valCreditShows" 
ControlToValidate="cboShowTitles"<BR>                                                                
runat="server" ErrorMessage="Required" InitialValue="Type to Search..." 
ValidationGroup="CreditGroup"></asp:RequiredFieldValidator><BR>                                                        
</td><BR>                                                    
</tr><BR>                                                    
<tr><BR>                                                        
<td 
class="formLabel-RightAlign"><BR>                                                            
Comment<BR>                                                        
</td><BR>                                                        
<td><BR>                                                            
<asp:TextBox ID="txtCreditComment" CssClass="textFields" runat="server" 
Width="200px"></asp:TextBox><BR>                                                        
</td><BR>                                                    
</tr><BR>                                                    
<tr><BR>                                                        
<td align="right" 
colspan="2"><BR>                                                            
<telerik:RadButton ID="btnSaveCredit" Skin="WebBlue" runat="server" 
Text="Save" 
ValidationGroup="CreditGroup"<BR>                                                                
OnClick="btnSaveCredit_Click"><BR>                                                            
</telerik:RadButton><BR>                                                        
</td><BR>                                                    
</tr><BR>                                                
</table><BR>                                            
</ContentTemplate><BR>                                        
</telerik:RadWindow><BR>                                    
</Windows><BR>                                
</telerik:RadWindowManager>

Partial code behind for btnSave_Click method...

<P> if (isUpdate)<BR> {<BR>        
talentCredit.UpdateTalentCredit(credit);<BR> }<BR> else<BR> {<BR>                        <BR>        
talentCredit.CreateTalentCredit(credit);</P>
<P> }<BR> SiteMaster masterPage = 
(SiteMaster)Page.Master;<BR> masterPage.SetAlertMessage("Credit has been 
Saved.", "green");</P>
<P> loadCredits(talentId);<BR> radgridCredits.DataBind();</P>
<P> <BR> RadWindow rw = 
RadWindowManager1.Windows[0];<BR>{<BR>      
rw.Visible=false;<BR>}<BR></P>

NOTE:  This code is in a Try/Catch and DOES NOT error out there.  It just errors out in VS2010 with the Javascript Error listed above after RadWindow.Visible=false gets called.

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 28 Apr 2011, 11:52 AM

Hello Mark,

You are trying to use the Visible property, while you should be using the VisibleOnPageLoad property to prevent the window from showing after the postback. The Visible property is just inherited and should not be used. The error you get is due to the fact that at this point of the page lifecycle the control is not yet created and thus cannot be found (which is exactly what the error states).



Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Window
Asked by
mark baer
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or