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

Closing RadWindow from code behind and refreshing Grid on Parent Page...

1 Answer 168 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 26 Apr 2011, 12:19 AM
I've seen a few different posts close to what I am trying to do, but I can't get any of them working.  Basically, I have a grid on my parent page with a button above it.  If the user clicks the button, it opens a RadWindow so the user can "Create new".  If the user selected an item from the grid, it opens the RadWindow and loads it with the data so the user can Edit the item.

When the user clicks the Save button IN the RadWindow, It calls a service to Save the Record, then I need it to CLOSE the RADWINDOW, and REFRESH the RadGrid on the Opening form.  To close the RadWindow, I am trying:

//RadWindowManager1.Windows[0].VisibleOnPageLoad = true;
//RadWindowManager1.Windows[0].Visible = false;

But I get Javascript Errors.  I tried different variations of the above approach and get Javascript errors most of the time.  I tried Calling a Javascript Method to close the window.  It seems to work sometimes, but not all of the time:

ScriptManager.RegisterClientScript(.....) which tries to find the RadWindow and close it...

here is most of my current code in the Save Method:

 

<P> if 
(isUpdate)<BR>                
{<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>                <BR>                //Reload 
the Credits Grid on the Page that opened 
the RadWindow...<BR>                loadCredits(talentId);<BR>                
radgridCredits.DataBind();<BR><BR>                //Now 
CLOSE the 
RadWindow...<BR>                RadWindowManager1.Windows[0].VisibleOnPageLoad 
true;<BR>                
RadWindowManager1.Windows[0].Visible = false;</P>

                
I get Javascript errors if I try to use the RadWindowManager1 approach, but if I try this on other Pages, this approach works fine....

RadWindowManager HTML:

       

 <telerik:RadWindowManager ID="RadWindowManager1" Behaviors="Close" 
runat="server"><BR>                                    
<Windows><BR>                                        
<telerik:RadWindow ID="radWinAddCredit" 
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="SERVICE PATH HERE" 
/><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>        

I like these controls for the most part, but the RadWindow seems to give me the most difficulty currently...ugh.

thanks

mark

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 28 Apr 2011, 01:44 PM
Hi Mark,

How do you open the RadWindow? Do you use the client-side API, or the server-side one?

You need to set VisibleOnPageLoad=false if you want to close the RadWindow from the server. In addition, depending on your scenario, you might also need to set EnableViewState=false for the RadWindowManager.



Greetings,
Georgi Tunev
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
Georgi Tunev
Telerik team
Share this question
or