... now you don't.
I can't believe I am having this problem. I can make the rad window appear via a client side call to open it, but after postback the very same javascript will not open it.
I have created a small test project to demonstrate the issue. I don't mind if this my own dumb fault, I just need to know why this is happening. :)
The form has a RadWindow inside a RadWindowManager and two buttons.
The first button is a regular html input type button that's 'onclick' calls the showWindow() JS function.
The 2nd button is an asp:Button that on click postback to its own event handler. This method simply sets a value on the textbox that is in the window, then it registers some javascript that will call the ShowWindow function. It is on this 2nd call the ShowWindow fails to find the Window.
Here is the relevant part of the aspx code.
The button event btnShowWindow_Click looks like this.
showWindow gets called just fine. However this time does not work as the window is not found. (the Alert shows NULL)
This has to be simple. What am I missing here?
I can't believe I am having this problem. I can make the rad window appear via a client side call to open it, but after postback the very same javascript will not open it.
I have created a small test project to demonstrate the issue. I don't mind if this my own dumb fault, I just need to know why this is happening. :)
The form has a RadWindow inside a RadWindowManager and two buttons.
The first button is a regular html input type button that's 'onclick' calls the showWindow() JS function.
The 2nd button is an asp:Button that on click postback to its own event handler. This method simply sets a value on the textbox that is in the window, then it registers some javascript that will call the ShowWindow function. It is on this 2nd call the ShowWindow fails to find the Window.
Here is the relevant part of the aspx code.
<
head
>
<
title
>Now you see it...</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
language
=
"javascript"
>
function showWindow() {
var win = $find("<%= RadWindow1.ClientID %>");
alert(win); // Is NULL after post back
win.show();
win.center();
}
</
script
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
>
<
ContentTemplate
>
<
asp:TextBox
ID
=
"tbTest"
runat
=
"server"
/>
</
ContentTemplate
>
</
telerik:RadWindow
>
</
Windows
>
</
telerik:RadWindowManager
>
<
input
type
=
"button"
onclick
=
"showWindow()"
value
=
"Client Side"
/>
<
asp:Button
ID
=
"btnShowWindow"
runat
=
"server"
OnClick
=
"btnShowWindow_Click"
Text
=
"Postback"
/>
</
form
>
</
body
>
</
html
>
The button event btnShowWindow_Click looks like this.
protected void btnShowWindow_Click(object sender, EventArgs e)
{
tbTest.Text = "The window will not appear";
string jScript = "showWindow();";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", jScript, true);
}
showWindow gets called just fine. However this time does not work as the window is not found. (the Alert shows NULL)
This has to be simple. What am I missing here?