I have the following markup in my code which is a RadGrid inside an UpdatePanel inside a div on a user control. Whenever I add a new row to the grid by clicking the 'Add Athlete' command bar button, it puts the grid into edit mode and sets focus to the first editor control perfectly. The grid is located near the bottom of my page. When I click 'Add Athlete' or edit an existing row, a post back is done as expected but the page's scrolled to position is lost; it always loads the page at 0,0 (top). I have tried several approaches with no luck:
1) Javascript to save the x/y scrolled positions into a hidden field and scroll to those positions on load
2) "Parent.Page.MaintainScrollPositionOnPostBack = true" in my page_load event
3) <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" /> in the grid's definition
4) Setting my DNN module definition to 'Support partial rending' on and off
5) Setting up a new project with a standard (non-master) page and using the following page declaration:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Tester.WebForm1" MaintainScrollPositionOnPostBack="true" %>
Nothing works. This is all hosted inside a custom user control which is a View module for DotNetNuke 6.
Any ideas?
My update panel and grid's definition:
1) Javascript to save the x/y scrolled positions into a hidden field and scroll to those positions on load
2) "Parent.Page.MaintainScrollPositionOnPostBack = true" in my page_load event
3) <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" /> in the grid's definition
4) Setting my DNN module definition to 'Support partial rending' on and off
5) Setting up a new project with a standard (non-master) page and using the following page declaration:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Tester.WebForm1" MaintainScrollPositionOnPostBack="true" %>
Nothing works. This is all hosted inside a custom user control which is a View module for DotNetNuke 6.
Any ideas?
My update panel and grid's definition:
<
div
>
<
asp:UpdatePanel
runat
=
"server"
ChildrenAsTriggers
=
"true"
ID
=
"upnlAthleteList"
>
<
ContentTemplate
>
<
telerik:RadGrid
ID
=
"grdAthletes"
runat
=
"server"
AllowAutomaticDeletes
=
"True"
AllowSorting
=
"True"
PageSize
=
"12"
AutoGenerateColumns
=
"False"
OnNeedDataSource
=
"grdAthletes_NeedDataSource"
OnItemCommand
=
"grdAthletes_ItemCommand"
OnPreRender
=
"grdAthletes_PreRender"
OnUpdateCommand
=
"grdAthletes_UpdateCommand"
Width
=
"758px"
OnDeleteCommand
=
"grdAthletes_DeleteCommand"
OnEditCommand
=
"grdAthletes_EditCommand"
OnItemDataBound
=
"grdAthletes_ItemDataBound"
ShowStatusBar
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
OnItemCreated
=
"grdAthletes_ItemCreated"
Skin
=
"Metro"
BorderStyle
=
"None"
CellSpacing
=
"0"
GridLines
=
"None"
ForeColor
=
"White"
BackColor
=
"Transparent"
ShowFooter
=
"True"
>
<
ValidationSettings
ValidationGroup
=
"AthletesGrid"
/>
<
ClientSettings
AllowKeyboardNavigation
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
KeyboardNavigationSettings
AllowSubmitOnEnter
=
"True"
AllowActiveRowCycle
=
"True"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
SaveScrollPosition
=
"true"
/>
<
ClientEvents
OnKeyPress
=
"OnKeyPress"
OnRowSelected
=
"RowSelected"
OnRowClick
=
"RowClick"
OnRowDblClick
=
"RowDblClick"
OnGridCreated
=
"GridCreated"
OnCommand
=
"GridCommand"
/>
<
Resizing
ShowRowIndicatorColumn
=
"False"
/>
</
ClientSettings
>
<
AlternatingItemStyle
BackColor
=
"LightGray"
BorderStyle
=
"None"
ForeColor
=
"Black"
/>
<
MasterTableView
NoMasterRecordsText
=
"No athletes to display."
EditMode
=
"InPlace"
CommandItemDisplay
=
"Bottom"
BorderStyle
=
"None"
BackColor
=
"Transparent"
ShowFooter
=
"False"
>
<
HeaderStyle
BorderStyle
=
"None"
Font-Bold
=
"True"
Font-Size
=
"Medium"
ForeColor
=
"White"
Height
=
"48px"
HorizontalAlign
=
"Left"
VerticalAlign
=
"Middle"
Wrap
=
"True"
/>
<
CommandItemStyle
CssClass
=
"rgCommandRow"
/>
<
FooterStyle
BorderStyle
=
"None"
CssClass
=
"grid-footer"
/>
<
CommandItemTemplate
>
<
div
>
<
asp:LinkButton
ID
=
"btnAddNew"
runat
=
"server"
CommandName
=
"AddNewRow"
>
<
img
style
=
"border:0px;vertical-align:middle;"
alt
=
"Add Athlete"
src
=
"Images/112_Plus_Green_32x42_72.png"
/> Add Athlete</
asp:LinkButton
>
</
div
>
</
CommandItemTemplate
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
ShowRefreshButton
=
"False"
AddNewRecordText
=
"Add Athlete"
>
</
CommandItemSettings
>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
CancelImageUrl
=
"Cancel.gif"
InsertImageUrl
=
"Update.gif"
UpdateImageUrl
=
"Update.gif"
Visible
=
"true"
Display
=
"true"
>
</
EditColumn
>
</
EditFormSettings
>
<
ItemStyle
BackColor
=
"White"
BorderStyle
=
"None"
ForeColor
=
"Black"
/>
<
AlternatingItemStyle
BackColor
=
"LightGray"
BorderStyle
=
"None"
ForeColor
=
"Black"
/>
<
EditItemStyle
BackColor
=
"Gainsboro"
BorderStyle
=
"None"
/>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
></
PagerStyle
>
<
Columns
>
<
telerik:GridBoundColumn
ConvertEmptyStringToNull
=
"False"
DataField
=
"RowCount"
EmptyDataText
=
""
FilterControlAltText
=
"Filter RowCount column"
HeaderText
=
""
SortExpression
=
"RowCount"
UniqueName
=
"RowCount"
ReadOnly
=
"true"
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"24px"
CssClass
=
"grid-header grid-header-first"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
VerticalAlign
=
"Middle"
Width
=
"24px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FirstName"
HeaderText
=
"First Name"
UniqueName
=
"FirstName"
ConvertEmptyStringToNull
=
"False"
SortExpression
=
"FirstName"
EmptyDataText
=
""
ColumnEditorID
=
"txtGridEdit_FirstName"
ColumnGroupName
=
"AthleteName"
ShowSortIcon
=
"False"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"True"
>
<
RequiredFieldValidator
ErrorMessage="<span
class
=
'red'
>* Required</
span
>"></
RequiredFieldValidator
></
ColumnValidationSettings
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"90px"
CssClass
=
"grid-header"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
Width
=
"100%"
VerticalAlign
=
"Top"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"MiddleName"
HeaderText
=
"M. Name"
UniqueName
=
"MiddleName"
ConvertEmptyStringToNull
=
"False"
EmptyDataText
=
""
SortExpression
=
"MiddleName"
ColumnEditorID
=
"txtGridEdit_MiddleName"
ColumnGroupName
=
"AthleteName"
ShowSortIcon
=
"False"
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"80px"
CssClass
=
"grid-header"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
Width
=
"100%"
VerticalAlign
=
"Top"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"LastName"
HeaderText
=
"Last Name"
UniqueName
=
"LastName"
ConvertEmptyStringToNull
=
"False"
SortExpression
=
"LastName"
EmptyDataText
=
""
ColumnEditorID
=
"txtGridEdit_LastName"
ColumnGroupName
=
"AthleteName"
ShowSortIcon
=
"False"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"True"
>
<
RequiredFieldValidator
ErrorMessage
=
"* Required"
></
RequiredFieldValidator
></
ColumnValidationSettings
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"90px"
CssClass
=
"grid-header"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
Width
=
"100%"
VerticalAlign
=
"Top"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Gender"
SortExpression
=
"Gender"
UniqueName
=
"Gender"
DataField
=
"Gender"
FilterControlAltText
=
"Filter Gender column"
ColumnEditorID
=
"cmbGridEdit_Gender"
ShowSortIcon
=
"False"
>
<
ItemTemplate
>
<%# DataBinder.Eval(Container.DataItem, "Gender") %></
ItemTemplate
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"ddlGender"
runat
=
"server"
>
<
Items
>
<
asp:ListItem
Text
=
"Female"
Value
=
"Female"
/>
<
asp:ListItem
Text
=
"Male"
Value
=
"Male"
Selected
=
"True"
/>
</
Items
>
</
asp:DropDownList
>
</
EditItemTemplate
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"80px"
CssClass
=
"grid-header"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
Width
=
"90%"
VerticalAlign
=
"Top"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridDateTimeColumn
ConvertEmptyStringToNull
=
"False"
DataField
=
"DoB"
FilterControlAltText
=
"Filter DoB column"
HeaderText
=
"Date of Birth"
SortExpression
=
"DoB"
UniqueName
=
"DoB"
DataFormatString
=
"{0:M/d/yy}"
DataType
=
"System.DateTime"
EmptyDataText
=
""
ColumnEditorID
=
"dtGridEdit_DoB"
ShowFilterIcon
=
"False"
EditDataFormatString
=
"M/d/yy"
MaxLength
=
"8"
ShowSortIcon
=
"False"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"True"
>
<
RequiredFieldValidator
ErrorMessage
=
"* Max age: 20"
ID
=
"valReqDoB"
></
RequiredFieldValidator
>
</
ColumnValidationSettings
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"106px"
CssClass
=
"grid-header"
/>
<
ItemStyle
Width
=
"100%"
HorizontalAlign
=
"Left"
VerticalAlign
=
"Top"
></
ItemStyle
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridMaskedColumn
ConvertEmptyStringToNull
=
"False"
DataField
=
"ZipCode"
DataFormatString
=
"{0:#####}"
FilterControlAltText
=
"Filter ZipCode column"
HeaderText
=
"Zip Code"
Mask
=
"#####"
SortExpression
=
"ZipCode"
UniqueName
=
"ZipCode"
EmptyDataText
=
""
ShowSortIcon
=
"False"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"True"
>
<
RequiredFieldValidator
ErrorMessage
=
"* Required"
></
RequiredFieldValidator
></
ColumnValidationSettings
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"80px"
CssClass
=
"grid-header"
/>
<
ItemStyle
Width
=
"100%"
HorizontalAlign
=
"Left"
VerticalAlign
=
"Top"
></
ItemStyle
>
</
telerik:GridMaskedColumn
>
<
telerik:GridBoundColumn
ConvertEmptyStringToNull
=
"False"
DataField
=
"Email"
FilterControlAltText
=
"Filter Email column"
HeaderText
=
"Email"
SortExpression
=
"Email"
UniqueName
=
"Email"
EmptyDataText
=
""
ColumnEditorID
=
"txtGridEdit_General_Large"
ShowSortIcon
=
"False"
>
<
ColumnValidationSettings
EnableRequiredFieldValidation
=
"True"
>
<
RequiredFieldValidator
ErrorMessage
=
"* Required"
ID
=
"valEmailColumnRequired"
/>
</
ColumnValidationSettings
>
<
HeaderStyle
Width
=
"160px"
Wrap
=
"False"
HorizontalAlign
=
"Left"
CssClass
=
"grid-header"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
Width
=
"100%"
VerticalAlign
=
"Top"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
ConvertEmptyStringToNull
=
"False"
DataField
=
"UniqueID"
EmptyDataText
=
""
FilterControlAltText
=
"Filter column column"
HeaderText
=
"Unique ID"
SortExpression
=
"UniqueID"
UniqueName
=
"UniqueID"
Visible
=
"False"
>
<
HeaderStyle
CssClass
=
"grid-header"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
VerticalAlign
=
"Top"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Edit"
FilterControlAltText
=
"Filter DeleteColumn column"
ImageUrl
=
"Images/126_Edit_16x16_72.png"
Text
=
""
UniqueName
=
"EditColumn"
Resizable
=
"false"
ConfirmDialogType
=
"RadWindow"
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"24px"
CssClass
=
"grid-header"
>
</
HeaderStyle
>
<
ItemStyle
Width
=
"100%"
HorizontalAlign
=
"Right"
VerticalAlign
=
"Top"
/>
</
telerik:GridButtonColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
FilterControlAltText
=
"Filter DeleteColumn column"
ImageUrl
=
"Images/305_Close_16x16_72.png"
Text
=
""
UniqueName
=
"DeleteColumn"
Resizable
=
"false"
ConfirmText
=
"Remove this athelete?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Remove"
ShowInEditForm
=
"True"
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"24px"
CssClass
=
"grid-header grid-header-last"
>
</
HeaderStyle
>
<
ItemStyle
Width
=
"100%"
HorizontalAlign
=
"Right"
VerticalAlign
=
"Top"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
><
EditItemStyle
BackColor
=
"Gainsboro"
BorderStyle
=
"None"
/>
<
FooterStyle
BorderStyle
=
"None"
/>
<
HeaderStyle
BorderStyle
=
"None"
Height
=
"48px"
HorizontalAlign
=
"Left"
VerticalAlign
=
"Middle"
/>
<
CommandItemStyle
CssClass
=
"rgCommandRow"
/>
<
ItemStyle
BackColor
=
"White"
BorderStyle
=
"None"
ForeColor
=
"Black"
/>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
></
PagerStyle
>
<
SelectedItemStyle
BorderStyle
=
"None"
/>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
><
br
/>
<
asp:Panel
id
=
"pnlMaxAthletesNote"
style
=
"display:none;"
runat
=
"server"
>
<
asp:Label
runat
=
"server"
ID
=
"lblMaxAthletes"
Text
=
"The maximum number of athletes for this team is {0}"
CssClass
=
"red"
/>
</
asp:Panel
>
<
telerik:GridTextBoxColumnEditor
ID
=
"txtGridEdit_FirstName"
runat
=
"server"
TextBoxStyle-Width
=
"98%"
/>
<
telerik:GridTextBoxColumnEditor
ID
=
"txtGridEdit_MiddleName"
runat
=
"server"
TextBoxStyle-Width
=
"98%"
/>
<
telerik:GridTextBoxColumnEditor
ID
=
"txtGridEdit_LastName"
runat
=
"server"
TextBoxStyle-Width
=
"98%"
/>
<
telerik:GridTextBoxColumnEditor
ID
=
"txtGridEdit_General_Large"
runat
=
"server"
TextBoxStyle-Width
=
"98%"
/>
<
telerik:GridDateTimeColumnEditor
runat
=
"server"
ID
=
"dtGridEdit_DoB"
TextBoxStyle-Width
=
"98%"
/>
<
telerik:GridDropDownListColumnEditor
ID
=
"cmbGridEdit_Gender"
runat
=
"server"
DropDownStyle-Width
=
"98%"
/>
</
ContentTemplate
>
</
asp:UpdatePanel
>
</
div
>