Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
197 views
Hi - yet another HttpModule conflict issue.  Unfortunately I can't figure out what specifically in my HttpModule causes the problem.

Anyway, the issue is that I get the dreaded Javascript error messages if I use my own HttpModule.  Unfortunately, I need to use it because it implements (using a mechanism proven to work reliably even with these errors) the ability to detect if the user hit the page refresh button.  It is critical that this detection exists in my application because of other mechanisms we need to use.  Anyway, below if the full code of my HttpModule and related classes:

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


 

Ed
Top achievements
Rank 1
 answered on 18 Jun 2008
1 answer
78 views

I have a very simple AJAX scenario I want to enable as easily as possible using the Telerik AJAX RadControl Q1 release (most recent).

I have dropdowns with 2000 items on them. These dropdowns aren't always used. I would like them to be populated with data if the user wants it. Otherwise, I don't want them populated.

I see lots of examples that involve writing some easy custom code, wiring it into the ItemsRequested handler, loading into a dataset, etc.

I would prefer to be as lazy as possible and use the VS.NET IDE as much as possible.

Questions:
1) Is there a way to make this work with a SqlDataSource rather than putting data access code in my code? I would rather call to the database in SqlDataSource than in inline code as you do in this example.

2) If the answer is "no" is there another simple way to delay the load of that data until the user clicks the down arrow?

If there is no way to do this outside of code I will probably query against my ORM framework (EntitySpaces), but I'm just curious if SqlDataSource can do this.

-KF
Simon
Telerik team
 answered on 18 Jun 2008
7 answers
179 views
Hello,

I uses radgrid to display a very lengthy log table from db.
My grid is using autogenerated columns but I tried to limit its with to a fixed px value, using scrolling horizontal and vertica.
The display area is ok but it appears that the real reserved grid size is computed with all the columns. So my page get very wide with a wide space to the right of the grid ?
I tried putting grid in a table, but no success.
Bug or (certainly) bad usage of parameters ?
How to solve this.
Here are part of my declarations:

<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> 
 


Thanks for help.
CS
Iana Tsolova
Telerik team
 answered on 18 Jun 2008
1 answer
90 views
see the sample "Advanced data-binding" base one 2008 Q1 sp2

After you clicked the page index rather than 1, you click any of the column headers order to sorting the grid. An error occurs : "Index 15 ..."

telerik, please try this.

Vlad
Telerik team
 answered on 18 Jun 2008
1 answer
122 views
I have html file like the following loaded into RadEditor.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>New Document</title>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
    </body>
</html>

However, when changed to html code mode, the code changed to the following.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title>New Document</title>
    </head>
    <body>
        <!--CTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//E-->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </body>
</html>

And I also notice that it has the problem when the file is saved as UTF8 file, but it preserve the html code if the file is saved as ANSI file.
And "<!--CTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//E-->" only appear when using IE, but not firefox.

Can anyone help?
Lini
Telerik team
 answered on 18 Jun 2008
1 answer
127 views
I have a RadComboBox, Rad Grid and a asp.net button on a web page.

The combobox's selected value is a parameter for the SQLdatasource used in the radgrid.
Properties set on the combobox are all default except:
Autopostback = true
Skin = office2007

<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" Skin="Office2007">
<Items>
<telerik:RadComboBoxItem runat="server" Text="One" Value="1" />
<telerik:RadComboBoxItem runat="server" Text="Two" Value="2" />
<telerik:RadComboBoxItem runat="server" Text="Three" Value="3" />
</Items>
<CollapseAnimation Duration="200" Type="OutQuint" />
</telerik:RadComboBox>

The button has custom code, not the radgrid export, that exports data to Excel.
The code on the button doesn't refer to the combobox at all.

The combobox works fine until you click on the button.
After the button is clicked, combobox will not drop down until you refresh the page. After the refresh, it works fine.


Is there a fix for this to work without the refresh?
Simon
Telerik team
 answered on 18 Jun 2008
0 answers
131 views

<

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?

</
ResourceTypes>

 is this possible in Resource Type Collection?

aman
Top achievements
Rank 1
 asked on 18 Jun 2008
9 answers
567 views
I'm currently trying to integrate the RadToolTipManager with the RadScheduler so that the appointment pops up with the default information and custom resources from the RadScheduler.  I've gotten that to work, but now everything tries to open a radtooltip, not just the scheduler.  I put in the RadScheduler in the TargetControls Collection and that solved the problem of everything having a tooltip, but now I can't retrieve the appointment information.

Here is the code I use to retrieve the appointment and it's info.  SelectedAppt successfully gets the index of the item from position 4 in the array, however when insert the scheduler as a target control the TargetControlID only has the name without any other info.

Is there a different way to give the Radscheduler ToolTips without having everything trying to use the RadToolTipManager?

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

Corey Alguire
Top achievements
Rank 1
 answered on 18 Jun 2008
2 answers
128 views
I'm running the ASPNET Ajax Q1 2008 trial with VS2005 / .NET 2.0 over WinXP SP2. I've been following the old tutorial, trying to do the sample where there is a dropdown for Today, LastWeek, etc, and two DatePickers. That works fine except when I try to use those controls and the Add button in a User control.

I think the basic question is how to ensure controls in a usercontrol are updated from a parent form. I am using the technique to pass the instance of the manager to the user control, and the control then registers its own components.  Here is the code from the page containing the control:
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);  
} 

And here is the code from the control:
public void ConfigureAjax( RadAjaxManager ajm ) {  
  ajm.AjaxSettings.AddAjaxSetting(  
       ddlDateRange , dpStart , RadAjaxLoadingPanel1);  
  ajm.AjaxSettings.AddAjaxSetting(  
       ddlDateRange , dpEnd , RadAjaxLoadingPanel1);  
} 

The StartDate and EndDate properties in the user control are simple:
return dpStart.SelectedDate; 

The issue is that the ddlDateRange does not fire SelectedDateChanged events on the datepickers. Those events are only fired when the user clicks the pbAdd button. The SelectedDate properties don't change, so the values returned through the public properties are essentially the original start/end dates from the controls.

I've read here that a panel needs to be put around the <uc1-/uc1> tags.  I've done that, tried setting the panel in the AddAjaxSetting, tried getting the controls to ajaxify themselves.  I'm really confused for many reasons which I will post elsewhere.  For now, can someone suggest the proper rules and technique (or just point me to a comprehensive doc) for communicating between a parent page child usercontrols?  TIA
Missing User
 answered on 18 Jun 2008
7 answers
202 views
Hi,

I'm testing the radpanel control but having problems with the NavigateUrl property. I'm using the control in a master page and setting the navigateurl dynamically in code. However, when I click on a panel item the page does not navigate, it appears to just post back and nothing more.

If i place the control in the content area of the default.aspx page, it navigates OK.

Can you advise on what I could try to help solve this?

Thanks,
Paul
Telerik team
 answered on 18 Jun 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?