Hi
I am trying to open a radwindow from C# on click of a button. I tried several codes available in the internet to invoke the js defined in the aspx page to open the radwindow but every time I get a js function undefined error. Please someone help me with a full solution.
Thanks in advance.
Ben
I am trying to open a radwindow from C# on click of a button. I tried several codes available in the internet to invoke the js defined in the aspx page to open the radwindow but every time I get a js function undefined error. Please someone help me with a full solution.
Thanks in advance.
Ben
5 Answers, 1 is accepted
0
Accepted

Shinu
Top achievements
Rank 2
answered on 02 Aug 2013, 09:18 AM
Hi Ben,
Please have a look into the following full code I tried to open a RadWindow from C# code using JavaScript defined in the ASPX.
ASPX:
JavaScript:
C#:
Thanks,
Shinu.
Please have a look into the following full code I tried to open a RadWindow from C# code using JavaScript defined in the ASPX.
ASPX:
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
Width
=
"450px"
Height
=
"450px"
NavigateUrl
=
"http://www.telerik.com"
>
</
telerik:RadWindow
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Open From Server"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
JavaScript:
<script type=
"text/javascript"
>
function
openRadWindow() {
var
radwindow = $find(
'<%=RadWindow1.ClientID %>'
);
radwindow.show();
}
</script>
C#:
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
string
script =
"function f(){openRadWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
;
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"key"
, script,
true
);
}
Thanks,
Shinu.
0
Hi,
You can see the following sticky note on the subject: Opening RadWindow from the server and try the solutions provided in it.
This help article could be helpful too: Using RadConfirm In Server Code.
Best regards,
Rumen
Telerik
You can see the following sticky note on the subject: Opening RadWindow from the server and try the solutions provided in it.
This help article could be helpful too: Using RadConfirm In Server Code.
Best regards,
Rumen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

Ben
Top achievements
Rank 1
answered on 02 Aug 2013, 06:19 PM
Thanks a lot lot Shinu. Hi Rumen, those links didn't help me since my primary aim was to invoke the js in aspx from C# code.
0

Ben
Top achievements
Rank 1
answered on 03 Sep 2013, 10:52 AM
Hi shinu. I have another query. How can I set the radwindow size as 90% of parent window even on browser resizing?
0
Accepted

Shinu
Top achievements
Rank 2
answered on 03 Sep 2013, 12:10 PM
Hi Ben,
Please check the following code.
ASPX:
JavaScript:
Thanks,
Shinu.
Please check the following code.
ASPX:
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Open RadWindow"
OnClientClicked
=
"openRadWindow"
AutoPostBack
=
"false"
>
</
telerik:RadButton
>
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
NavigateUrl
=
"http://www.telerik.com"
>
</
telerik:RadWindow
>
JavaScript:
<script type=
"text/javascript"
>
var
$ = $telerik.$;
var
radwindow;
function
pageLoad() {
radwindow = $find(
"<%= RadWindow1.ClientID%>"
);
}
function
openRadWindow() {
radwindow.show();
setWindowsize();
}
$(window).resize(
function
() {
if
(radwindow.isVisible()) {
setWindowsize();
}
});
function
setWindowsize() {
var
viewportWidth = $(window).width();
var
viewportHeight = $(window).height();
radwindow.setSize(Math.ceil(viewportWidth * 90 / 100), Math.ceil(viewportHeight * 90 / 100));
radwindow.center();
}
</script>
Thanks,
Shinu.