RadWindow: Opening windows from C#
Need to open a webpage in a radWindow from a button click event. Attempted to do this from client side but, it appears and then immediately disappears. I Think the button click is causing a postback to the server... Therefore, I'm currently attempting to solve this issue with server side code (C#) posted below.
Problem: Need to open rad windows without adding them to the window collection or remove them from the window collection on close. They aren't being removed from the window collection on closing of the rad window. This results in the same window opening for the number of times the new button is pressed. First click opens one window, the second time the new button is clicked two windows open, etc... Any ideas?
C# - Multiple pages opening
RadWindow newWindow = new RadWindow();
newWindow.NavigateUrl = "WebPage.aspx";
newWindow.Top = Unit.Pixel(22);
newWindow.VisibleOnPageLoad = true;
newWindow.Modal = true;
newWindow.Left = Unit.Pixel(0);
newWindow.Height = 530;
newWindow.Width = 1000;
winMgr.Windows.Add(newWindow);
JavaScript - Post Bac开发者_Go百科k issue? Page opens and immediately disappears.
var oManager = '<%=winMgr.ClientID %>';
var oManager = window.radopen("WebPage.aspx", null);
oManager.setSize(1000, 530); //Width, Height
oManager.center();
oManager.SetActive();
Thanks for your help!
As per Alison's solution, rad window is getting displayed on button click; but is disappearing again immediately. I tried using the code below. It is working fine in my case.
<script type="text/javascript">
function openRadWin()
{
radopen("http://www.google.com", "RadWindow1");
}
</script>
<asp:Button ID="Button1" Text="Show Window" runat="server" OnClientClick="openRadWin();" />
Hope, it will be useful for someone.
You need to return false after clicking your button.
Try setting your button/JavaScript to something similar to the following:
Button (aspx)
<asp:Button ID="btnDoSomething" runat="server" Text="Do Something" OnClientClick="return myFunction();" />
JavaScript
function myFunction() {
var oManager = window.radopen("WebPage.aspx", null);
oManager.setSize(1000, 530); //Width, Height
oManager.center();
oManager.SetActive();
return false;
}
First - the basics :) Do you want to open the RadWindow on the client (via JavaScript) or on the server?
Case 1 - on the client: Alison is right - if you want to open the RadWindow on the client (and there is no server-side event hooked to that postback element), you need to cancel the postback. This is done either by using OnClientClick="return myFunction();" and "return false;" at the end of the function itself (like Alison suggested), or:
OnClientClick="myFynction(); return false;"
When the client click is cancelled, there should be no postback.
Case 2 - on the server: RadWindow is shown from the server by setting VisibleOnPageLoad to true. Note that the RadWindow / RadWindowManager however, keeps their state across postbacks, that includes all server-side properties, including VisibleOnPageLoad. This being said, if you want to show RadWindow only once, you need to also set EnableViewState=false for the RadWindowManager that you are using.
精彩评论