のスクロール位置を維持したいRadPanelBar
。自動更新中のRadPanelBar
ページに配置されます。バーを下にスクロールするとRadPanelBar
、ページの更新時に上に移動します。すべきではありません。次のコードで処理しようとしていますが、機能しません。私は何かが足りないのですか?
これが私のJavaScriptです
<script type="text/javascript">
function SetScrollPositionOnlineContacts() {
//var pane = splitter.GetPaneById("RadPanelBarRoster");
//document.getElementById("RadPanelBarRoster").scrollTop;
var splitter =$find("RadSplitterBottomParent");
var intY = splitter.GetPaneById("RadPanelBarRoster").scrollTop;
var date = new Date();
date.setTime(date.getTime() + (1 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = "cookieDivOnlineContacts"
+ "="
+ intY
+ expires + "; path=/";
//document.title = intY;
}
function readCookieOnlineContacts(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
</script>
これが私のHTML
コードです:
<telerik:RadSplitter ID="RadSplitterBottomParent" runat="server" Height="100%"
Width="100%" Orientation="Vertical" BackColor="#ECECFF" Skin="WebBlue"
LiveResize="True" SplitBarsSize="" HeightOffset="124" Visible="true"
BorderSize="0" PanesBorderSize="0">
<!-- Start Left Roster Panel -->
<telerik:RadPane ID="RadPaneRoster" runat="server" Width="220px"
Scrolling="None">
<telerik:RadContextMenu ID="RadContextMenuRoster" runat="server"
OnClientItemClicked="onRosterContextMenuClick"
EnableShadows="True">
<Items>
<telerik:RadMenuItem runat="server" Text="View
Conversation">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text="View Properties">
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text="Add to Favourites"
Enabled="False">
</telerik:RadMenuItem>
</Items>
</telerik:RadContextMenu>
<telerik:RadPanelBar ID="RadPanelBarRoster" runat="server"
Skin="Metro"
Width="100%" onscroll="SetScrollPositionOnlineContacts()"
Height="3000px" OnClientItemClicked="onRosterClick"
OnClientContextMenu="onRosterContextMenu"
PersistStateInCookie="True" Style="width: 100%; border-top: 0;
border-bottom: 0;
z-index: 2" ExpandMode="FullExpandedItem" EnableViewState="True"
ViewStateMode="Inherit"
OnItemClick="RadPanelBarRoster_ItemClick">
</telerik:RadPanelBar>
</telerik:RadPane>
</telerik:RadSplitter>
これが私のコードビハインドページです:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
StringBuilder sbScript = new StringBuilder();
sbScript.Append(
"<script language='JavaScript' type='text/javascript'>");
//For order Panel
sbScript.Append(
"document.cookie = cookieDivOnlineContacts + \"" +
"=\" + \"\" + -1 + \"; path=/\";");
sbScript.Append("</script>");
//// Make use ScriptManager to register the script
ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"@@@@MyCallBackAlertScript",
sbScript.ToString(),
false);
}
StringBuilder sbScript1 = new StringBuilder();
sbScript1.Append(
"<script language='JavaScript' type='text/javascript'>");
//For order Panel
sbScript1.Append(
"var strCookOnlineContacts = " +
"readCookieRfqOrder(\"cookieDivOnlineContacts\"); " +
"document.getElementById(\"RadPanelBarRoster\").scrollTop " +
"= strCookOnlineContacts;");
sbScript1.Append("</script>");
// Make use ScriptManager to register the script
ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"@@@@MyCallBackAlertScript",
sbScript1.ToString(),
false);
}
私は初心者ですので、適切なサポートを提供してください。