This is a migrated thread and some comments may be shown as answers.

RadScriptManager and EnableHistory

2 Answers 237 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Nate
Top achievements
Rank 1
Nate asked on 02 Feb 2009, 07:53 PM
I need to add history points in search pages of my application. The search is executed inside a RadAjaxPanel and displays the results in a RadGrid. When the user selects and item in the RadGrid they are sent to another page. When the user clicks the browser back button the RadGrid is empty. So I need to add a history point to re-populate the RadGrid.

Below is some code from a very simple test app that is similar to the architecture of my application. The RadScriptManager is in a master page and with a textbox and button in a user control.

When I place the textbox and button inside an UpdatePanel the Ajax EnableHistory works but the same code does not work with RadAjaxPanel. I have also tried using RadAjaxManager which also does not work. History points are added successfully using RadAjaxPanel and the ScriptManagerProxy.Navigate fires, but the textbox is not updated.

UpdatePanel has an Update method to force an update when its UpdateMode is Conditional but RadAjaxPanel does not have an Update method which is probably why UpdatePanel works.

What can I do to get the EnableHistory feature to work with RadAjaxPanel?

Thanks
Nate

Main.Master

<%

@ Master Language="VB" AutoEventWireup="false" CodeBehind="Main.master.vb" Inherits="AjaxEnableHistory.Main" %>

 

 

<!

 

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>

 

 

 

<asp:ContentPlaceHolder ID="head" runat="server">

 

 

 

</asp:ContentPlaceHolder>

 

 

 </

 

head>

 

 

 <

 

body>

 

 

<form id="form1" runat="server">

 

<div>

 

<telerik:RadScriptManager ID="scriptMgr" runat="server" EnableHistory="True" />

 

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

 

</asp:ContentPlaceHolder>

 

</div>

 

</form>

</

 

body>

 

 

</

 

html>

Default.aspx

 

 

<%

@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Main.Master" CodeBehind="Default.aspx.vb" Inherits="AjaxEnableHistory._Default" %>

 

<%

@ Register Src="Default.ascx" TagName="Default" TagPrefix="uc1" %>

 

<

 

asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

 

 

<uc1:Default ID="Default1" runat="server" />

</

 

asp:Content>

Default.ascx

 

<%

@ Control Language="vb" AutoEventWireup="false" CodeBehind="Default.ascx.vb" Inherits="AjaxEnableHistory._Default1" %>

 

<

 

asp:ScriptManagerProxy ID="scriptMgr" runat="server" />

 

 

 

 

 

<%

 

--<telerik:RadAjaxLoadingPanel ID="ajxLoading" runat="server">

 

Loading...</telerik:RadAjaxLoadingPanel>

<telerik:RadAjaxPanel ID="ajxPanel" runat="server" LoadingPanelID="ajxLoading">

<telerik:RadTextBox ID="txt" runat="server" />

<asp:Button ID="btn" runat="server" Text="Ajax Postback" />

</telerik:RadAjaxPanel>--

 

 

%>

 

 

<

 

asp:UpdateProgress ID="updProgress" runat="server" AssociatedUpdatePanelID="updPanel">

 

 

<ProgressTemplate>Loading...</ProgressTemplate>

</

 

asp:UpdateProgress>

 

<

 

asp:UpdatePanel ID="updPanel" runat="server" UpdateMode="Conditional">

 

 

<ContentTemplate>

 

 

<telerik:RadTextBox ID="txt" runat="server" />

 

 

<asp:Button ID="btn" runat="server" Text="Ajax Postback" />

 

 

</ContentTemplate>

</

 

asp:UpdatePanel>

Default.ascx.vb

 

Private

 

Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click

 

    Threading.Thread.Sleep(3000)

    AddHistoryPoint()

 

End Sub

 

 

 

 

Private Sub scriptMgr_Navigate(ByVal sender As Object, ByVal e As System.Web.UI.HistoryEventArgs) Handles scriptMgr.Navigate

    Threading.Thread.Sleep(3000)

    txt.Text = e.State(txt.ID)

    updPanel.Update() 'Update method not available with RadAjaxPanel

 

End Sub

 

 

 

 

Protected Sub AddHistoryPoint()

 

 

    Dim sm As ScriptManager = ScriptManager.GetCurrent(Me.Page)

 

 

    If sm.IsInAsyncPostBack AndAlso Not sm.IsNavigating Then

 

 

        Dim state As New NameValueCollection()

        state(txt.ID) = txt.Text

        ScriptManager.GetCurrent(

Me.Page).AddHistoryPoint(state, "Test Title")

 

 

    End If

 

 

End Sub

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 05 Feb 2009, 12:18 PM
Hello Nate,

You can try using the RaisePostBackEvent() method of the RadajaxPanel control to ensure the textbox is updated. You can read more about this here.

I hope this helps.

Greetings,
Pavel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Nate
Top achievements
Rank 1
answered on 05 Feb 2009, 03:56 PM

RaisePostBackEvent seemed to have the same effect as UpdatePanel.Update. The value of my textbox was updated.

 

 

Private Sub scriptMgr_Navigate(ByVal sender As Object, ByVal e As System.Web.UI.HistoryEventArgs) Handles scriptMgr.Navigate

 

Threading.Thread.Sleep(3000)

txt.Text = e.State(txt.ID)

 

'updPanel.Update() 'not available with RadAjaxPanel

 

ajxPanel.RaisePostBackEvent(

Nothing)

 

 

End Sub

Thanks
Nate

 

Tags
Ajax
Asked by
Nate
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Nate
Top achievements
Rank 1
Share this question
or