@@ -45,7 +45,7 @@ In the event handler, you can check if the request is an AJAX PostBack (IsInAsyn
45
45
protected void ReportViewer1_PreRender (object sender , EventArgs e )
46
46
{
47
47
// Access the Application's ScriptManager
48
- ScriptManager sm = RadScriptManager .GetCurrent (Page );
48
+ ScriptManager sm = ScriptManager .GetCurrent (Page );
49
49
50
50
// Check if the request is an AJAX Post Back
51
51
if (sm .IsInAsyncPostBack )
@@ -58,10 +58,10 @@ protected void ReportViewer1_PreRender(object sender, EventArgs e)
58
58
protected void InitializeReportViewer (ReportViewer reportViewer )
59
59
{
60
60
// 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 );
62
62
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 );
65
65
66
66
// Concatenate both scripts
67
67
string reportingScripts = string .Empty ;
@@ -86,18 +86,22 @@ protected void InitializeReportViewer(ReportViewer reportViewer)
86
86
````
87
87
```` VB
88
88
Protected 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)
90
90
91
91
If sm.IsInAsyncPostBack Then
92
92
InitializeReportViewer( CType (sender, ReportViewer))
93
93
End If
94
94
End Sub
95
95
96
96
Protected 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)
100
102
103
+ 'Concatenate both scripts
104
+ Dim reportingScripts As String = String .Empty
101
105
For Each match As Match In matches
102
106
reportingScripts += match.Value
103
107
Next
@@ -109,7 +113,9 @@ Protected Sub InitializeReportViewer(ByVal reportViewer As ReportViewer)
109
113
Sys.Application.remove_load(pageLoadHandler) ;
110
114
}}
111
115
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 )
113
119
End If
114
120
End Sub
115
121
````
0 commit comments