public class RefreshAction
{
// ***********************************************************
// Constants
public const string LastRefreshTicketEntry = "__LASTREFRESHTICKET";
public const string CurrentRefreshTicketEntry = "__CURRENTREFRESHTICKET";
public const string PageRefreshEntry = "IsPageRefresh";
// ***********************************************************
// ***********************************************************
// Manage to check if the F5 button has been pressed
public static void Check(HttpContext ctx)
{
// Initialize the ticket slot
EnsureRefreshTicket(ctx);
// Read the last ticket served in the session (from Session)
int lastTicket = GetLastRefreshTicket(ctx);
// Read the ticket of the current request (from a hidden field)
int thisTicket = GetCurrentRefreshTicket(ctx);
// Compare tickets
if (thisTicket > lastTicket ||
(thisTicket == lastTicket && thisTicket == 0))
{
UpdateLastRefreshTicket(ctx, thisTicket);
ctx.Items[PageRefreshEntry] =
false;
}
else
{
ctx.Items[PageRefreshEntry] =
true;
}
}
// ***********************************************************
// ***********************************************************
// Ensure that the slot for the last ticket served isn't null
private static void EnsureRefreshTicket(HttpContext ctx)
{
// Initialize the session slots for the page (Ticket) and the module (LastTicketServed)
if (ctx.Session[LastRefreshTicketEntry] == null)
ctx.Session[LastRefreshTicketEntry] = 0;
}
// ***********************************************************
// ***********************************************************
// Return the ticket of the last request in the session
private static int GetLastRefreshTicket(HttpContext ctx)
{
// Extract and return the last ticket
return Convert.ToInt32(ctx.Session[LastRefreshTicketEntry]);
}
// ***********************************************************
// ***********************************************************
// Return the ticket of the last request in the session
private static int GetCurrentRefreshTicket(HttpContext ctx)
{
return Convert.ToInt32(ctx.Request[CurrentRefreshTicketEntry]);
}
// ***********************************************************
// ***********************************************************
// Return the ticket of the last request in the session
private static void UpdateLastRefreshTicket(HttpContext ctx, int ticket)
{
ctx.Session[LastRefreshTicketEntry] = ticket;
}
// ***********************************************************
}
public class RefreshModule : IHttpModule
{
// ***********************************************************
// IHttpModule::Init
public void Init(HttpApplication app)
{
// Register for pipeline events
app.AcquireRequestState +=
new EventHandler(this.OnAcquireRequestState);
}
// ***********************************************************
// ***********************************************************
// IHttpModule::Dispose
public void Dispose()
{
}
// ***********************************************************
// ***********************************************************
// Determine if a F5 or back/fwd action is in course
private void OnAcquireRequestState(object sender, EventArgs e)
{
// Get access to the HTTP context
HttpApplication app = (HttpApplication)sender;
HttpContext ctx = app.Context;
// Check F5 action
RefreshAction.Check(ctx);
return;
}
// ***********************************************************
}
This is then used by a custom Page class that my app inherits from that allows me to check if this is a page refresh or not. The relevant methods from my Page class are below:
// **************************************************************
// Indicates if the page is being viewed in response to F5 hit
public bool IsPageRefresh
{
get
{
object o = HttpContext.Current.Items[RefreshAction.PageRefreshEntry];
if (o == null)
return false;
return (bool)o;
}
}
// **************************************************************
// **************************************************************
// Increase the internal counter used to generate refresh tickets
public void TrackRefreshState()
{
InitRefreshState();
int ticket = Convert.ToInt32(Session[RefreshTicketCounter]) + 1;
Session[RefreshTicketCounter] = ticket;
}
// **************************************************************
#region
Private Members
// **************************************************************
// Create the hidden field to store the current request ticket
private void SaveRefreshState()
{
int ticket = Convert.ToInt32(Session[RefreshTicketCounter]) + 1;
RegisterHiddenField(
RefreshAction.CurrentRefreshTicketEntry, ticket.ToString());
}
// **************************************************************
// **************************************************************
// Ensure that the ticket counter is initialized
private void InitRefreshState()
{
if (Session[RefreshTicketCounter] == null)
Session[RefreshTicketCounter] = 0;
}
// **************************************************************
// **************************************************************
// Handle the PreRender event
private void RefreshPage_PreRender(object sender, EventArgs e)
{
SaveRefreshState();
}
// **************************************************************
If there is anything obvious in the above that would interfere with RadAjax, could you suggest how to avoid breaking it? I do understand that I may be able to resolve the problem by having the application(s) reference the scripts and set UseEmbedded Scripts="False", but these HttpModule and Page classes are actually being used as our base classes on several applications. It becomes somewhat less than ideal from a software release distribution standpoint if we have to modify our page markup to reference the right version path of the RadControls for several applications every time we upgrade to a new release of RadControls. It also tends to make the applications know more about the underlying controls than I would prefer, since normally it wouldn;t be typical to have to add the script references on the pages using them.
Thanks,
-Ed
| <table cellspacing="2" cellpadding="2" width="900px" align="left" border="0"> |
| <tr valign="top"> |
| <td valign="top" align="left" width="200px" > |
| ...... |
| </td> |
| <td valign="top" align="left" width="200px"> |
| ...... |
| </td> |
| </tr> |
| <tr> |
| <td colspan='2'> |
| <asp:Panel ID="MonitoringPanel" Runat="server"> |
| <div style="width:900px"> |
| <Telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" PageSize='20' |
| AllowPaging="True" AllowCustomPaging='true' VirtualItemCount='100000' |
| AllowSorting="True" GridLines="None" ShowGroupPanel="True" ShowStatusBar='true' Width='100%' > |
| <MasterTableView TableLayout='Fixed' > |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <Columns> |
| <Telerik:GridClientSelectColumn UniqueName='SelectColumn' HeaderStyle-Width="30px"/> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings AllowDragToGroup="True"> |
| <Selecting AllowRowSelect="True" /> |
| <Scrolling AllowScroll="True" EnableVirtualScrollPaging="True" UseStaticHeaders="True" SaveScrollPosition="True" /> |
| <Resizing EnableRealTimeResize="True" ResizeGridOnColumnResize="False" AllowColumnResize="True" ClipCellContentOnResize="true" /> |
| </ClientSettings> |
| <HeaderStyle Width="100px" /> |
| <PagerStyle Mode='NumericPages' /> |
| </Telerik:RadGrid> |
| </div> |
| </asp:Panel> |
| <br /> |
| <asp:label id="LabelNoData" runat="server" Visible="False" /> |
| <asp:Label Id="ErrorLabel" Runat="server" CssClass="Error" Visible="false"></asp:Label> |
| </td> |
| </tr> |
| </table> |

<
ResourceTypes>
<telerik:ResourceType KeyField="SalesRepID" Name="SalesRep" TextField="SalesRep"
ForeignKeyField="SalesRepID" DataSourceID="odsSalesRep" />
<asp:TextBox id="ID" runat="server"/> ? is this possible in Resource Type Collection?
is this possible in Resource Type Collection?
protected
void RadToolTipManager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)
{
try
{
char[] splitters = { '_' };
string[] SelectedAppt = (e.TargetControlID.Split(splitters));
int aptIndex = Convert.ToInt32(SelectedAppt[4]);
Appointment apt = RadScheduler1.Appointments[aptIndex];
AppointmentToolTip tooltip = LoadControl("AppointmentToolTip.ascx") as AppointmentToolTip;
tooltip.TargetAppointment = apt;
RadToolTipManager1.Visible =
true;
e.UpdatePanel.ContentTemplateContainer.Controls.Add(tooltip);
}
catch (Exception ex)
{
}
}
Thanks,
-David
| protected void Page_Load( object sender , EventArgs e ) |
| { |
| if ( !Page.IsPostBack ) |
| { |
| DateRangePicker1.ConfigureAjax(RadAjaxManager1); |
| } |
| } |
| protected void pbAdd_Click( object sender , EventArgs e ) |
| { |
| AccessDataSource1.FilterExpression = String.Format( |
| "TransactionDate>='{0}' AND TransactionDate<='{1}'" , |
| DateRangePicker1.StartDate , DateRangePicker1.EndDate); |
| } |
| public void ConfigureAjax( RadAjaxManager ajm ) { |
| ajm.AjaxSettings.AddAjaxSetting( |
| ddlDateRange , dpStart , RadAjaxLoadingPanel1); |
| ajm.AjaxSettings.AddAjaxSetting( |
| ddlDateRange , dpEnd , RadAjaxLoadingPanel1); |
| } |
| return dpStart.SelectedDate; |