I've the following issue with the radWindow -
I've two buttons "Open Popup" and "Do Postback". Open Popup opens a page in radwindow and Do Postback just does an empty postback.
I'm opening a page in the radwindow when Open Popup is clicked. I've a cancel button in the popup page which simply closes the radwindow (using client side script).
Now when i do an empty postback the popup is getting opened again. Why is that happening?
I've uploaded the project here to duplicate the issue - http://dl.dropbox.com/u/3971218/Code%20Samples/RadWindowAsPopup.zip.
Kindly check it out.
Regards
NLV
23 Answers, 1 is accepted
Hi,
Since you are setting the VisibleOnPageLoad property to True, the window will be open for every postback. So one suggestion would be opening the window from client code as shown below.
C# code for invoking the client event handler which opens the window:
string script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(showWindow);</script>"; |
ClientScript.RegisterStartupScript(this.GetType(), "showWindoww", script); |
JavaScript:
<script type="text/javascript"> |
function showWindow() { |
radopen('url', ''); // Opens the window |
} |
</script> |
-Shinu.
I want to pass the URL to the showWindow function which i've built in the code. How can i do that?
Thank you.
Regards
NLV
string script = String.Format("<script language='javascript' type='text/javascript'>Sys.Application.add_load(showWindow('{0}');</script>",url); |
<script type="text/javascript"> |
function showWindow(url) { |
radopen(url, ''); // Opens the window |
} |
</script> |
I'll give it a try again.
Regards
NLV
There are several ways to resolve the problem. What I suggest is that you put the url from the server in a HiddenField and then on the client reference the filed and get the url value.
Best wishes,
Svetlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you Svetlina.
Regards
NLV
Protected Sub ShowCustomerWindow()
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "showWindow();", True)
End Sub
function showWindow() {
var oWindowCust = $find('<%= rwJobEventLog.ClientID %>');
oWindowCust.show();
}
<telerik:RadWindow ID="rwJobEventLog" runat="server" Title="Job Event Log" Width="350"
Height="520" VisibleOnPageLoad="true" Behaviors="Move,Pin,Resize" InitialBehaviors="Pin"
KeepInScreenBounds="true" OffsetElementID="lnkbtnViewJobEventLog" Left="580"
Visible="false" CssClass="rwBasket" DestroyOnClose="true">
<ContentTemplate>
<div style="text-align: center">
<table>
<tr>
<td style="width: 75%">
<asp:Button ID="btnJobEventLogCloseWindow" runat="server" Text="Close Window" OnClientClick="return CloseEventLogWindow();"
/>
</td>
<%-- <td style="width: 25%" align="right">
<asp:Image ID="Image1" runat="server" ImageUrl="~/DesktopModules/phdcc.CodeModule/images/help.gif" />
</td>
--%>
</tr>
</table>
<asp:GridView ID="gvJobEventLog" runat="server" CellPadding="2" Width="95%" CssClass="gridviewSpacing gvBasket"
AutoGenerateColumns="True">
<Columns>
</Columns>
</asp:GridView>
</div>
<br />
</ContentTemplate>
</telerik:RadWindow>
I already answered your other thread and for your convenience and for others who need more detailed information about the AJAX client lifecycle, I pasted it below:
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 RadWindow) 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 RadWindow 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.
You can find additional information about this here:
This being said, you should modify your code e.g in the following manner:
Protected
Sub
lbAddCustomer_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
lbAddCustomer.Click
Page.ClientScript.RegisterStartupScript(
Me
.
GetType
(),
"key"
,
"Sys.Application.add_load(showWindow);"
,
True
)
End
Sub
<script type=
"text/javascript"
>
function
showWindow() {
Sys.Application.remove_load(showWindow);
var
oWindowCust = $find(
'<%= rwCustomer.ClientID %>'
);
oWindowCust.show();
}
</script>
I hope that the provided explanation and resource are helpful .
Regards,
Svetlina
the Telerik team
Thanks for your reply but when I am trying to find my
radwindow ( var
oWindowCust = $find(
'<%= rwCustomer.ClientID %>'
);
I am getting undefined.
And when I set VisibleOnPageLoad=true and visible=true then my radwindow appears at page load
and I can close my radwindow at client side using javascript. I don't understand really what's
happening.
function GetEventLogWindow() {
var oWindowViewJobLog = $find('<%= rwJobEventLog.ClientID %>');
return oWindowViewJobLog;
}
function GetCustomerWindow() {
var oWindowCust = $find('<%= rwCustomer.ClientID %>');
return oWindowCust;
}
function CloseCustomerWindow() {
GetCustomerWindow().close();
}
function CloseEventLogWindow() {
GetEventLogWindow().close()
}
I am afraid that I could not understand what is the problem - would you please prepare a simple, fully runnable reproduction page and post the full and working source code here? In case you have followed my suggestion, you can directly pass the ClientID from the server, no need to use code blocks to evaluate it. If you have decided, on the other hand, to use the VisibleOnPageLoad property, I did not understand what is the issue you face. At last, the Visible property should not be used - it is only inherited and not implemented.
This being said, to be able to help I will really need to have an overall understanding on the configuration - please provide sample working full source code along with detailed explanations on each reproduction step and I will modify it in order to meet your requirements.
Svetlina
the Telerik team
My Scenario
It's a very simple scenario ... Just place three radwindows in a webform with three buttons and make sure that radwindow should be hidden at page load (visible = false , VisibleOnPageLoad =true) and will only be visible when user clicks a button. Radwindow should be opened from code-behind and close it at client-side using javascript.
Steps:
1) Three Radwindows
2) Three Buttons
3) Open from Code-Behind
4) Close By using javascript
When you implement this what will happen that when you open a first window you will either get undefined or if it opened successfully then close it and when you try to open a second window a first window will also appears again. I hope you understand and if you still need a code for that simple scenario then reply me back.
In this case, the easiest way to achieve what you want is the following:
1) Wrap the RadWindows in a RadWindowManager with EnableViewState="false".
2) Use the VisibleOnPageLoad property to show the RadWindow you want.
Wrapping the RadWindows with a manager with disabled ViewState will remove the problem with reopening the first RadWindow when opening the second. Note, that this will work in the case of RadWindows wrapped in a RadWindowManager.
Svetlina
the Telerik team
I was having the same issue like yours before. To solve this issue I created a new separate aspx page with all the controls that I need to show on the page then generate the RADWindow on the fly via button click event. Make sure to assign the NavigateURL property of the RADWindow to the new aspx page that you created. See example below. Hope this helps.
protected
void
lnkBtn_Click(
object
sender, CommandEventArgs e)
{
string
navigateURL =
string
.Format(
"OrderDetail.aspx{0}"
, StringHelpers.EncryptQueryString(e.CommandArgument.ToString()));
//Create RadWindow dynamically
RadWindow orderDetailWindow =
new
RadWindow();
orderDetailWindow.ID =
"OrderDetailWindow"
;
orderDetailWindow.Title =
"Order Detail"
;
//orderDetailWindow.Skin = "Web20";
orderDetailWindow.Width = Unit.Pixel(960);
orderDetailWindow.Height = Unit.Pixel(600);
orderDetailWindow.VisibleStatusbar =
false
;
orderDetailWindow.ShowContentDuringLoad =
false
;
orderDetailWindow.Modal =
true
;
orderDetailWindow.AutoSize =
false
;
orderDetailWindow.Behaviors = WindowBehaviors.Close | WindowBehaviors.Move;
orderDetailWindow.NavigateUrl = navigateURL;
orderDetailWindow.VisibleOnPageLoad =
true
;
gridOrders.Controls.Add(orderDetailWindow);
}
I am afraid that there is some misunderstanding between us - do you want to have the RadWindows opened or not on postbacks? It seems that we can't get a good enough understanding on your overall scenario, please prepare a simple reproduction demo which is fully runnable and send its full source code. Put along very detailed step by step instructions and detailed explanations on the exact actual and desired result on each of the steps. Once we receive this, we will be able to provide you a faster and better support rather then exchanging pieces of information which seem to be insufficient.
Best wishes,
Svetlina
the Telerik team
When Open from Code-Behind we set RadWindows1.VisibleOnPageLoad ="True" it popup and the ViewState save this property to TRUE!!!! Then when we close by client script the RadWindows hide correcly.
But on postBack the server recall ViewState and the property RadWindows1.VisibleOnPageLoad will set to TRUE and will popUp.
I suggest to set in Page_load server side event RadWindows1.VisibleOnPageLoad = "False"; as default!
If you set EnableViewState="false" you lost all property set in server side, is dangereus.
thanks
The behavior you report is actually the expected one - when a property is set it should be persisted in the ViewState. The property says that the RadWindow should be visible on page load - it is absolutely valid scenario to have it always initially opened on the page. However, as already explained you can use the same property and reset it to false where needed - this is up to your custom logic. Another option is to execute opening script from the server - it is up to you to choose the approach which meets your preferences.
What exactly do you mean by saying that "If you set EnableViewState="false" you lost all property set in server side, is dangereus"? Disabling the ViewState is a valid approach which is actually often used in general ASP.NET to make the pages lighter and faster. You will lose properties you set only if you set them once - e.g on initial load. You could set them always or use the page's ViewState or Session object to keep the setting.
Please, choose one of the already suggested 3 approaches and let us know if you need further assistance with the approach you have chosen.
Svetlina
the Telerik team
Good day!
Here's my scenario:
- on web page there's a button "A" to pop up rad window
- rad window has some controls (rad grid) which may cause post backs, so after those post-backs rad-window needs to be opened
- rad window also has a link-button B to save and close the form
So, when user needs to open the dialog, he clicks button A, and in click-event handler I set VisibleOnPageLoad to "true".
When user clicks button B to close the form, in the event handler I set VisibleOnPageLoad = "false".
Everything works fine for the exception, that user can also close the window with the "X" button in the top-right corner. In this case the window will re-appear after the next post-back. The solution I use is to make the window to do the post-back when X button is clicked. It can be done by rendering post-back script from "B" button to the javascript function and assigning this function to OnClientClose property of the RadWindow.
Here's the code to render the method:
protected
override
void
Render(HtmlTextWriter writer)
{
ScriptManager.RegisterClientScriptBlock(
this
, Page.GetType(),
"scrCancelWindow"
,
string
.Format(@
"function onWindowClose(sender, eventArgs){{{0};}}"
,
Page.ClientScript.GetPostBackEventReference(lbCancel, lbCancel.ID,
true);
),
true
);
base
.Render(writer);
}
Make sure you render post-back script in overriden Render method of the page, otherwise you'll get an exception. Hope this will help someone.
Amazing!
Regards.
Thankyou Fransesco.
My Issue is in radwindow when i click on "close" button page is loading after page is loaded radwindow will be closed but we want to close the window without page load....is their any way to solve this issue???
When RadWIndow's [X] close button (at the top right corner, in LTR mode) is clicked it only executes a JavaScript function that hides the popup. In case either the content, or the main page reloads, then some custom code is most likely involved, so you should look for OnClientClose or OnClientBeforeClose handlers that can be doing this.
In case you have a custom button on the content page of the RadWindow and you want to close it via this button's client-side code, please examine the following demo's content page which shows such an example: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx.
Regards,
Marin Bratanov
Telerik