@@ -45,7 +45,7 @@ In the event handler, you can check if the request is an AJAX PostBack (IsInAsyn
4545protected void ReportViewer1_PreRender (object sender , EventArgs e )
4646{
4747 // Access the Application's ScriptManager
48- ScriptManager sm = RadScriptManager .GetCurrent (Page );
48+ ScriptManager sm = ScriptManager .GetCurrent (Page );
4949
5050 // Check if the request is an AJAX Post Back
5151 if (sm .IsInAsyncPostBack )
@@ -58,10 +58,10 @@ protected void ReportViewer1_PreRender(object sender, EventArgs e)
5858protected void InitializeReportViewer (ReportViewer reportViewer )
5959{
6060 // Search pattern for regex
61- string pattern = string .Format (@" syncReportViewerState\([^)]* \);|jQuery\('#{0}'\)\.telerik_ReportViewer\([^)]* \);" , reportViewer .ID );
61+ string pattern = string .Format (@" ( syncReportViewerState\('{0}'.*? \);|jQuery\('#{0}'\)\.telerik_ReportViewer\(.*? \);) " , reportViewer1 .ID );
6262
63- // find the two functions containing all the params from the generated HTML string of reportViewer.ToString()
64- MatchCollection matches = Regex .Matches (reportViewer .ToString (), pattern );
63+ // Find the two functions containing all the params from the generated HTML string of reportViewer.ToString()
64+ MatchCollection matches = Regex .Matches (reportViewer .ToString (), pattern , RegexOptions . Singleline );
6565
6666 // Concatenate both scripts
6767 string reportingScripts = string .Empty ;
@@ -86,18 +86,22 @@ protected void InitializeReportViewer(ReportViewer reportViewer)
8686````
8787```` VB
8888Protected Sub ReportViewer1_PreRender( ByVal sender As Object , ByVal e As EventArgs)
89- Dim sm As ScriptManager = RadScriptManager .GetCurrent(Page)
89+ Dim sm As ScriptManager = ScriptManager .GetCurrent(Page)
9090
9191 If sm.IsInAsyncPostBack Then
9292 InitializeReportViewer( CType (sender, ReportViewer))
9393 End If
9494End Sub
9595
9696Protected Sub InitializeReportViewer( ByVal reportViewer As ReportViewer)
97- Dim pattern As String = String .Format( "syncReportViewerState\([^)]*\);|jQuery\('#{0}'\)\.telerik_ReportViewer\([^)]*\);" , reportViewer.ID)
98- Dim matches As MatchCollection = Regex.Matches(reportViewer.ToString(), pattern)
99- Dim reportingScripts As String = String .Empty
97+ 'Search pattern for regex
98+ Dim pattern As String = String .Format( @"(syncReportViewerState\('{0}'.*?\);|jQuery\('#{0}'\)\.telerik_ReportViewer\(.*?\);)" , reportViewer1.ID)
99+
100+ 'Find the two functions containing all the params from the generated HTML string of reportViewer.ToString()
101+ Dim matches As MatchCollection = Regex.Matches(reportViewer.ToString(), pattern, RegexOptions.Singleline)
100102
103+ 'Concatenate both scripts
104+ Dim reportingScripts As String = String .Empty
101105 For Each match As Match In matches
102106 reportingScripts += match.Value
103107 Next
@@ -109,7 +113,9 @@ Protected Sub InitializeReportViewer(ByVal reportViewer As ReportViewer)
109113 Sys.Application.remove_load(pageLoadHandler) ;
110114 }}
111115 Sys.Application.add_load(pageLoadHandler) ;", reportingScripts)
112- ScriptManager.RegisterStartupScript(Page, Page.[GetType](), Guid.NewGuid().ToString(), startupScript, True )
116+
117+ 'Register a Startup Script that will be executed after the AJAX Post Back
118+ ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), startupScript, True )
113119 End If
114120End Sub
115121````
0 commit comments