<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ScaleAnalysisTemplateTest.aspx.cs" Inherits="DSSAnalytics.DashboardWidgets.ScaleAnalysisTool.ScaleAnalysisTemplateTest" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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"
>
<
telerik:RadScriptManager
ID
=
"MuniWebScriptMgr"
runat
=
"server"
EnablePartialRendering
=
"true"
AsyncPostBackTimeout
=
"36000"
>
<
Scripts
>
<
asp:ScriptReference
Path
=
"~/scripts/jquery-1.3.2.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
asp:ImageButton
runat
=
"server"
ID
=
"IMG_Excel"
OnClick
=
"DownloadAsExcel"
CssClass
=
"ExcelBtnStyle"
ImageUrl
=
"../../images/excel.png"
ToolTip
=
"Export to Excel"
/>
<
div
id
=
"gridCtrl"
runat
=
"server"
>
</
div
>
</
form
>
</
body
>
</
html
>
RadGrid r;
protected
void
Page_Init(
object
sender, EventArgs e)
{
BuildRadGrid();
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
private
void
BuildRadGrid()
{
r =
new
RadGrid();
r.ID =
"ScaleAnalysisSummaryByRow"
;
r.GridLines = GridLines.None;
r.EnableEmbeddedSkins =
false
;
r.MasterTableView.AutoGenerateColumns =
false
;
r.MasterTableView.TableLayout = GridTableLayout.Fixed;
r.AllowSorting =
true
;
r.MasterTableView.AllowNaturalSort =
true
;
r.ClientSettings.Scrolling.SaveScrollPosition =
false
;
r.EnableViewState =
false
;
r.Height = Unit.Pixel(450);
r.Width = Unit.Pixel(1200);
r.MasterTableView.Width = Unit.Pixel(900);
GridBoundColumn boundColumn1 =
new
GridBoundColumn();
boundColumn1.HeaderText =
"Name"
;
boundColumn1.DataField =
"name"
;
boundColumn1.UniqueName =
"name"
;
boundColumn1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
boundColumn1.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
boundColumn1.HeaderStyle.VerticalAlign = VerticalAlign.Bottom;
boundColumn1.HeaderStyle.Width = Unit.Pixel(150);
boundColumn1.HeaderStyle.Font.Bold =
true
;
r.Columns.Add(boundColumn1);
GridTemplateColumn boundColumn2 =
new
GridTemplateColumn();
boundColumn2.HeaderText =
"Series"
;
boundColumn2.ItemTemplate =
new
ScaleAnalysisRowSeriesNameTemplate();
boundColumn2.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
boundColumn2.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
boundColumn2.HeaderStyle.VerticalAlign = VerticalAlign.Bottom;
boundColumn2.HeaderStyle.Width = Unit.Pixel(130);
boundColumn2.HeaderStyle.Font.Bold =
true
;
r.Columns.Add(boundColumn2);
GridBoundColumn boundColumn3 =
new
GridBoundColumn();
boundColumn3.HeaderText =
"Amount"
;
boundColumn3.DataField =
"amt"
;
boundColumn3.UniqueName =
"amt"
;
boundColumn3.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
boundColumn3.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
boundColumn3.HeaderStyle.VerticalAlign = VerticalAlign.Bottom;
boundColumn3.HeaderStyle.Width = Unit.Pixel(60);
boundColumn3.HeaderStyle.Font.Bold =
true
;
boundColumn3.DataFormatString =
"{0:N0}"
;
r.Columns.Add(boundColumn3);
int
year = 2010;
string
col1 =
"col1_d1"
;
string
col2 =
"col1_d2"
;
string
col3 =
"col1_d3"
;
string
col4 =
"col1_d4"
;
GridTemplateColumn templateColumn =
new
GridTemplateColumn();
templateColumn.HeaderTemplate =
new
ScaleAnalysisRowHeaderTemplate(year);
templateColumn.ItemTemplate =
new
ScaleAnalysisRowItemTemplate(col1 , col2, col3 , col4);
r.Columns.Add(templateColumn);
year = 2011;
col1 =
"col2_d1"
;
col2 =
"col2_d2"
;
col3 =
"col2_d3"
;
col4 =
"col2_d4"
;
GridTemplateColumn templateColumn2 =
new
GridTemplateColumn();
templateColumn2.HeaderTemplate =
new
ScaleAnalysisRowHeaderTemplate(year);
templateColumn2.ItemTemplate =
new
ScaleAnalysisRowItemTemplate(col1, col2, col3, col4);
r.Columns.Add(templateColumn2);
r.ClientSettings.Scrolling.AllowScroll =
true
;
r.ClientSettings.Scrolling.UseStaticHeaders =
true
;
r.ClientSettings.Selecting.AllowRowSelect =
true
;
r.NeedDataSource +=
new
GridNeedDataSourceEventHandler(Grid_NeedDataSource);
gridCtrl.Controls.Add(r);
}
protected
void
Grid_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataTable dt =
new
DataTable();
dt.Columns.Add(
"name"
,
typeof
(String));
dt.Columns.Add(
"series"
,
typeof
(String));
dt.Columns.Add(
"amt"
,
typeof
(Decimal));
dt.Columns.Add(
"col1_d1"
,
typeof
(Decimal));
dt.Columns.Add(
"col1_d2"
,
typeof
(Decimal));
dt.Columns.Add(
"col1_d3"
,
typeof
(Decimal));
dt.Columns.Add(
"col1_d4"
,
typeof
(Decimal));
dt.Columns.Add(
"col2_d1"
,
typeof
(Decimal));
dt.Columns.Add(
"col2_d2"
,
typeof
(Decimal));
dt.Columns.Add(
"col2_d3"
,
typeof
(Decimal));
dt.Columns.Add(
"col2_d4"
,
typeof
(Decimal));
DataRow dr = dt.NewRow();
dr[
"name"
] =
"John Smith"
;
dr[
"series"
] =
"S1"
;
dr[
"amt"
] = 200.98;
dr[
"col1_d1"
] = 120;
dr[
"col1_d2"
] = 11;
dr[
"col1_d3"
] = 12090;
dr[
"col1_d4"
] = 1221;
dr[
"col2_d1"
] = 320;
dr[
"col2_d2"
] = 110;
dr[
"col2_d3"
] = 1190;
dr[
"col2_d4"
] = 121;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[
"name"
] =
"Mary Jones"
;
dr[
"series"
] =
"S2"
;
dr[
"amt"
] = 200.98;
dr[
"col1_d1"
] = 120;
dr[
"col1_d2"
] = 11;
dr[
"col1_d3"
] = 12090;
dr[
"col1_d4"
] = 1221;
dr[
"col2_d1"
] = 20;
dr[
"col2_d2"
] = 10;
dr[
"col2_d3"
] = 190;
dr[
"col2_d4"
] = 21;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[
"name"
] =
"Test User"
;
dr[
"series"
] =
"S3"
;
dr[
"amt"
] = 200.98;
dr[
"col1_d1"
] = 120;
dr[
"col1_d2"
] = 11;
dr[
"col1_d3"
] = 12090;
dr[
"col1_d4"
] = 1221;
dr[
"col2_d1"
] = 200;
dr[
"col2_d2"
] = 109;
dr[
"col2_d3"
] = 1990;
dr[
"col2_d4"
] = 218;
dt.Rows.Add(dr);
RadGrid grid = (RadGrid)source;
grid.DataSource = dt;
}
protected
void
DownloadAsExcel(
object
sender, EventArgs e)
{
try
{
r.ExportSettings.IgnorePaging =
true
;
r.ExportSettings.OpenInNewWindow =
true
;
r.ExportSettings.ExportOnlyData =
true
;
r.ExportSettings.FileName =
"ExcelSample"
;
r.MasterTableView.ExportToExcel();
}
catch
(Exception ex)
{
throw
ex;
}
}
}
internal
class
ScaleAnalysisRowSeriesNameTemplate : ITemplate
{
protected
LiteralControl securityWindow;
public
ScaleAnalysisRowSeriesNameTemplate()
{
}
public
void
InstantiateIn(System.Web.UI.Control container)
{
Table table =
new
Table();
table.CellSpacing = 0;
table.CellPadding = 0;
table.Width = Unit.Percentage(100);
table.BorderStyle = BorderStyle.None;
TableRow tr1 =
new
TableRow();
TableCell td1 =
new
TableCell();
td1.BorderStyle = BorderStyle.None;
td1.BorderWidth = Unit.Pixel(0);
securityWindow =
new
LiteralControl();
securityWindow.DataBinding +=
new
EventHandler(lControl_Series_DataBinding);
td1.Controls.Add(securityWindow);
td1.HorizontalAlign = HorizontalAlign.Left;
td1.VerticalAlign = VerticalAlign.Middle;
td1.Controls.Add(securityWindow);
tr1.Cells.Add(td1);
table.Rows.Add(tr1);
container.Controls.Add(table);
}
public
void
lControl_Series_DataBinding(
object
sender, EventArgs e)
{
LiteralControl l = (LiteralControl)sender;
GridDataItem container = (GridDataItem)l.NamingContainer;
string
securityWinLink =
"openwin('"
+ ((DataRowView)container.DataItem)[
"series"
].ToString() +
"')"
;
l.Text =
"<a onclick="
+ securityWinLink +
" title='Click to Open series details'><b><u>"
+ ((DataRowView)container.DataItem)[
"series"
].ToString() +
"</u></b></a>"
;
}
}
internal
class
ScaleAnalysisRowHeaderTemplate : ITemplate
{
private
int
_year;
public
ScaleAnalysisRowHeaderTemplate(
int
year)
{
_year = year;
}
public
void
InstantiateIn(System.Web.UI.Control container)
{
Table table =
new
Table();
table.CellSpacing = 0;
table.CellPadding = 0;
table.Width = Unit.Percentage(100);
table.BorderStyle = BorderStyle.None;
TableRow tr0 =
new
TableRow();
TableRow tr1 =
new
TableRow();
TableRow tr2 =
new
TableRow();
int
colspan = 2;
TableCell td0 =
new
TableCell();
TableCell td1 =
new
TableCell();
TableCell td2 =
new
TableCell();
TableCell td3 =
new
TableCell();
TableCell td4 =
new
TableCell();
td0.HorizontalAlign = HorizontalAlign.Center;
td0.Text = _year.ToString();
td0.Font.Bold =
true
;
tr0.Cells.Add(td0);
table.Rows.Add(tr0);
colspan = 2;
td1.Text =
"Data1"
;
td2.Text =
"Data2"
;
td3.Text =
"Data3"
;
td4.Text =
"Data4"
;
td1.HorizontalAlign = HorizontalAlign.Center;
td2.HorizontalAlign = HorizontalAlign.Center;
td3.HorizontalAlign = HorizontalAlign.Center;
td4.HorizontalAlign = HorizontalAlign.Center;
td1.Font.Bold =
true
;
td2.Font.Bold =
true
;
td3.Font.Bold =
true
;
td4.Font.Bold =
true
;
td1.Width = Unit.Percentage(50);
td2.Width = Unit.Percentage(50);
tr1.Cells.Add(td1);
tr1.Cells.Add(td2);
tr2.Cells.Add(td3);
tr2.Cells.Add(td4);
table.Rows.Add(tr1);
table.Rows.Add(tr2);
td0.ColumnSpan = colspan;
container.Controls.Add(table);
}
}
internal
class
ScaleAnalysisRowItemTemplate : ITemplate
{
string
_col1;
string
_col2;
string
_col3;
string
_col4;
string
_view;
protected
LiteralControl lControl1;
protected
LiteralControl lControl2;
protected
LiteralControl lControl3;
protected
LiteralControl lControl4;
int
_colcounter;
public
ScaleAnalysisRowItemTemplate(
string
col1,
string
col2,
string
col3,
string
col4)
{
_col1 = col1;
_col2 = col2;
_col3 = col3;
_col4 = col4;
}
public
void
InstantiateIn(System.Web.UI.Control container)
{
Table table =
new
Table();
table.CellSpacing = 0;
table.CellPadding = 0;
table.Width = Unit.Percentage(100);
table.BorderStyle = BorderStyle.None;
TableRow tr1 =
new
TableRow();
TableRow tr2 =
new
TableRow();
TableCell td1 =
new
TableCell();
TableCell td2 =
new
TableCell();
TableCell td3 =
new
TableCell();
TableCell td4 =
new
TableCell();
lControl1 =
new
LiteralControl();
lControl1.ID =
"lControl1"
+ _col1 + _colcounter.ToString();
lControl1.DataBinding +=
new
EventHandler(lControl_col1_DataBinding);
lControl2 =
new
LiteralControl();
lControl2.ID =
"lControl2"
+ _col2 + _colcounter.ToString();
lControl2.DataBinding +=
new
EventHandler(lControl_col2_DataBinding);
lControl3 =
new
LiteralControl();
lControl3.ID =
"lControl3"
+ _col3 + _colcounter.ToString();
lControl3.DataBinding +=
new
EventHandler(lControl_col3_DataBinding);
lControl4 =
new
LiteralControl();
lControl4.ID =
"lControl4"
+ _col4 + _colcounter.ToString(); ;
lControl4.DataBinding +=
new
EventHandler(lControl_col4_DataBinding);
td1.Controls.Add(lControl1);
td2.Controls.Add(lControl2);
td3.Controls.Add(lControl3);
td4.Controls.Add(lControl4);
td1.HorizontalAlign = HorizontalAlign.Center;
td2.HorizontalAlign = HorizontalAlign.Center;
td3.HorizontalAlign = HorizontalAlign.Center;
td4.HorizontalAlign = HorizontalAlign.Center;
td1.BorderStyle = BorderStyle.None;
td1.BorderWidth = Unit.Pixel(0);
td2.BorderStyle = BorderStyle.None;
td2.BorderWidth = Unit.Pixel(0);
td3.BorderStyle = BorderStyle.None;
td3.BorderWidth = Unit.Pixel(0);
td4.BorderStyle = BorderStyle.None;
td4.BorderWidth = Unit.Pixel(0);
td1.Width = Unit.Percentage(50);
td2.Width = Unit.Percentage(50);
tr1.Cells.Add(td1);
tr1.Cells.Add(td2);
tr2.Cells.Add(td3);
tr2.Cells.Add(td4);
table.Rows.Add(tr1);
table.Rows.Add(tr2);
_colcounter++;
container.Controls.Add(table);
}
public
void
lControl_col1_DataBinding(
object
sender, EventArgs e)
{
LiteralControl l = (LiteralControl)sender;
GridDataItem container = (GridDataItem)l.NamingContainer;
l.Text = String.Format(
"{0:N0}"
, ((DataRowView)container.DataItem)[_col1]);
}
public
void
lControl_col2_DataBinding(
object
sender, EventArgs e)
{
LiteralControl l = (LiteralControl)sender;
GridDataItem container = (GridDataItem)l.NamingContainer;
l.Text = String.Format(
"{0:N2}"
, ((DataRowView)container.DataItem)[_col2]);
}
public
void
lControl_col3_DataBinding(
object
sender, EventArgs e)
{
LiteralControl l = (LiteralControl)sender;
GridDataItem container = (GridDataItem)l.NamingContainer;
l.Text = String.Format(
"{0:N2}"
, ((DataRowView)container.DataItem)[_col3]);
}
public
void
lControl_col4_DataBinding(
object
sender, EventArgs e)
{
LiteralControl l = (LiteralControl)sender;
GridDataItem container = (GridDataItem)l.NamingContainer;
l.Text = String.Format(
"{0:N0}"
, ((DataRowView)container.DataItem)[_col4]);
}
}
function
OpenChildRadWindow(p_sURL, p_iWidth, p_iHeight) {
var
l_oBrowserWnd = GetRadWindow().BrowserWindow;
setTimeout(
function
() {
var
l_oWindow = l_oBrowserWnd.radopen(p_sURL,
"newRadWindow"
, p_iWidth, p_iHeight);
l_oWindow.radParent =
this
;
l_oWindow.InitialBehaviors = Telerik.Web.UI.WindowBehaviors.None;
l_oWindow.set_modal(
true
);
}, 0);
}
<
telerik:radcombobox
id
=
"cmbBox"
runat
=
"server"
width
=
"185px"
DataTextField
=
"Text"
DataValueField
=
"Value"
DataCheckedField
=
"IsChecked"
MaxHeight
=
"185px"
CheckBoxes
=
"True"
EnableCheckAllItemsCheckBox
=
"True"
Filter
=
"None"
Sort
=
"None"
EnableTextSelection
=
"False"
OnClientItemChecked
=
"cmbBoxItemChecked"
/>
cmbBox.Items.Add(
new
RadComboBoxItem(
"separator1"
) { IsSeparator =
true
});
cmbBox.Items.Add(
new
RadComboBoxItem
{ Text =
"Name1"
, Value =
"Value1"
, Checked =
false
});
cmbBox.Items.Add(
new
RadComboBoxItem(
"separator2"
) { IsSeparator =
true
});
cmbBox.Items.Add(
new
RadComboBoxItem
{ Text =
"Name2"
, Value =
"Value2"
, Checked =
false
});
cmbBox.Items.Add(
new
RadComboBoxItem(
"separator3"
) { IsSeparator =
true
});
cmbBox.Items.Add(
new
RadComboBoxItem
{ Text =
"Name3"
, Value =
"Value3"
, Checked =
false
});
function
cmbBoxItemChecked(sender, eventArgs)
{
sender.set_text(
"my custom text according to internal logic, based on checked item"
);
}
Good day,
We’ve been experiencing the invalid webresource exception for at least a few weeks now, mainly on IE7 and IE8, although we’ve also seen it on IE9 and Firefox (but far less frequently).
2012-06-06 14:10:23,238 [20] [admin] [xbqai0wdtzjrg2akwu0hjrc1] [(null)] ERROR Global - Unhandled exception was [System.Web.HttpException (0x80004005): This is an invalid webresource request.
2012-06-06 16:11:49,758 [17] [(null)] [(null)] [(null)] ERROR Global - Application_Error : unhandled exception processing /[AppName]/WebResource.axd?d=Suu-bg3mCuf0dFdR6OaZkvX4qIzt-FMOe6pPRuU-iok0iBRX7G8SkmhJ6f6sVdRz5vgh3rhLmGeuyVCZQ7NlYAkluB8OomTcba5DZz_nqarySe1LWUgUVAdCHlVY9NrY1NCgWnu8yVgPuJfiygFy-Q2&t=634739782657507859
We fixed this by using fixed Machine Keys in IIS, and once all the users had deleted their Temporary Internet Files, we did not see the exception again. At least, until we deployed the latest build of our code onto the server.
Now, the issue is recurring fairly randomly and what happens is on certain pages our application, the selected menu item disappears as do the background images for RadTabStrips. What’s interesting is that it only happens on Internet Explorer (even 9), and if we open Developer Tools and check “Always refresh from server” under Cache, the problem goes away, but returns as soon as we uncheck that option.
We then went to our Temporary Internet Files folder and noticed that there are a number of files with names like: Telerik.Web.UI.WebResource.axd?compress=x&Telerik.Web.UI%2c+Version%3d2012.1.215.40%2c+Culture%3dneutral%2c …
We then opened all of these into Notepad and took the each of the problematic URLs in the error log to try and find the culprit, but to no avail.
We do have the following code on our Master page (if that helps):
<telerik:RadScriptManager ID="RadScriptManager" runat="server" EnableScriptGlobalization="true" EnablePageMethods="true" EnableScriptCombine="true">
<CompositeScript>
<Scripts>
<asp:ScriptReference Path="~/Javascript/jquery1.js" />
<asp:ScriptReference Path="~/Javascript/JavaScript1.js" />
</Scripts>
</CompositeScript>
</telerik:RadScriptManager>
We are unable to provide a sample of the issue, as we can’t reproduce it locally (other than with automatically generated keys).
Any advice you can provide would be greatly appreciated.
Kind regards,
Graeme