Hello.
Sample code TestPage.aspx:
Sample code TestUserControl.ascx:
Code throws "Sys.WebForms.PageRequestManagerServerErrorException: Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error". I need create usercontrol in ajaxrequest, usercontrol has javascriptcode with server code(<%%>). How resolve this error?
Sample code TestPage.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="TelerikDynamicUserControlJsApp.testPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
style
=
"display:none"
>
<
rad:RadScriptManager
runat
=
"server"
EnablePageMethods
=
"true"
>
<
Scripts
>
<%--Needed for JavaScript IntelliSense in VS2010--%>
<%--For VS2008 replace RadScriptManager with ScriptManager--%>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
rad:RadScriptManager
>
<
rad:RadAjaxManager
runat
=
"server"
>
<
AjaxSettings
>
<
rad:AjaxSetting
AjaxControlID
=
"TestButton"
>
<
UpdatedControls
>
<
rad:AjaxUpdatedControl
ControlID
=
"TestPlaceHolder"
/>
</
UpdatedControls
>
</
rad:AjaxSetting
>
</
AjaxSettings
>
</
rad:RadAjaxManager
>
</
div
>
<
div
>
<
asp:Button
ID
=
"TestButton"
runat
=
"server"
Text
=
"Test"
Width
=
"60"
OnClick
=
"TestButton_OnClick"
/>
<
asp:PlaceHolder
ID
=
"TestPlaceHolder"
runat
=
"server"
/>
</
div
>
</
form
>
</
body
>
</
html
>
protected
void
TestButton_OnClick(
object
sender, EventArgs e)
{
TestPlaceHolder.Controls.Add(LoadControl(
"TestUserControl.ascx"
));
}
Sample code TestUserControl.ascx:
<%@ Control Language=
"C#"
AutoEventWireup=
"true"
CodeBehind=
"TestUserControl.ascx.cs"
Inherits=
"TelerikDynamicUserControlJsApp.TestUserControl"
%>
<rad:RadScriptBlock>
<script language=
"text/javascript"
>
function GridCreated() {
alert(
"<%= Grid.ClientID %>"
);
}
</script>
</rad:RadScriptBlock>
<div style=
"display:none"
>
<rad:RadAjaxManagerProxy runat=
"server"
>
<AjaxSettings>
<rad:AjaxSetting AjaxControlID=
"Grid"
>
<UpdatedControls>
<rad:AjaxUpdatedControl ControlID=
"Grid"
/>
</UpdatedControls>
</rad:AjaxSetting>
</AjaxSettings>
</rad:RadAjaxManagerProxy>
</div>
<rad:RadGrid ID=
"Grid"
runat=
"server"
AllowSorting=
"true"
>
<ClientSettings>
<ClientEvents OnGridCreated=
"GridCreated"
/>
</ClientSettings>
</rad:RadGrid>
public
class
TestData
{
public
string
TestField {
get
;
set
; }
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
Grid.DataSource =
new
TestData[] {
new
TestData { TestField =
"Test"
} };
}
Code throws "Sys.WebForms.PageRequestManagerServerErrorException: Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error". I need create usercontrol in ajaxrequest, usercontrol has javascriptcode with server code(<%%>). How resolve this error?