Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
303 views
Hi,

I have the scheduler largely working as it should - inserting and updating are working fine as is deleting stand-alone appointments and recurring series. The problem is when I try to delete an Exception - I get the error: "Cannot locate the parent of appointment with ID = 'x'. Ensure that the parent appointment with ID = 'x' exists and is loaded." I've performed a watch on the Scheduler control at the moment this error is being caught and can see the parent appointment with the right ID exists (It's a string datatype though - could this be the problem?).

So far as I can tell I'm doing everything by the book - saving on AppointmentInsert and AppointmentUpdate, deleting on AppointmentDelete. The error is being thrown after Page_Load (where I bind the scheduler control if it's not postback) but before it reaches the AppointmentDelete event handler. The code is attached.

    <asp:ScriptManager ID="scmEvents" runat="server" OnAsyncPostBackError="scmEvents_AsyncPostBackError" /> 
    <telerik:RadAjaxManager ID="ramEvents" runat="server"> 
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="rscEvents"> 
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rscEvents" LoadingPanelID="ralEvents" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadAjaxLoadingPanel ID="ralEvents" runat="server" Transparency="10" BackColor="#E0E0E0" InitialDelayTime="500"> 
        <asp:Image ID="imgLoading" runat="server" style="margin-top: 200px;" ImageUrl="" BorderWidth="0px" AlternateText="Loading..." /> 
    </telerik:RadAjaxLoadingPanel> 
    <telerik:RadScheduler ID="rscEvents" runat="server" Width="750px" Height="561px" style="margin: 0 auto;" Skin="Office2007" SelectedView="MonthView" ShowViewTabs="False" 
        OnAppointmentInsert="rscEvents_AppointmentInsert" OnAppointmentUpdate="rscEvents_AppointmentUpdate" OnAppointmentDelete="rscEvents_AppointmentDelete" OnAppointmentDataBound="rscEvents_AppointmentDataBound" 
        DataKeyField="EventId" DataSubjectField="EventName" DataStartField="StartDate" DataEndField="EndDate" DataRecurrenceField="RecurrenceRule"  
        DataRecurrenceParentKeyField="RecurrenceParentId" StartInsertingInAdvancedForm="True" StartEditingInAdvancedForm="True" DisplayRecurrenceActionDialogOnMove="True" EnableResourceEditing="False"> 
        <TimelineView UserSelectable="False" /> 
    </telerik:RadScheduler> 
     
    /// <summary> 
    /// I'm using a form of the MVP pattern which is why all of the event handlers look the way they do.  
    /// </summary> 
    public partial class Events : BasePage, IEventsView 
    { 
        #region Fields 
 
        private EventsPresenter presenter; 
 
        private int eventId = -1; 
        private string eventName = String.Empty; 
        private string eventDescription = String.Empty; 
        private DateTime startDate = DateTime.MinValue; 
        private DateTime endDate = DateTime.MinValue; 
        private string recurrenceRule = String.Empty; 
        private string recurrenceParentId = String.Empty; 
        #endregion 
        #region Constructor 
 
        /// <summary> 
        /// Initializes a new instance of the <see cref="Events"/> class. 
        /// </summary> 
        public Events() 
        { 
            presenter = new EventsPresenter( this, new EventsDataService(), DefaultInjection.GetDefault() ); 
            presenter.Init(); 
        } 
        #endregion 
        #region Events 
 
        /// <summary> 
        /// Occurs when the form is loaded 
        /// </summary> 
        public event EventHandler FormLoad; 
 
        /// <summary> 
        /// Occurs when an appointment is inserted. 
        /// </summary> 
        public event EventHandler AppointmentInsert; 
 
        /// <summary> 
        /// Occurs when an appointment is updated. 
        /// </summary> 
        public event EventHandler AppointmentUpdate; 
 
        /// <summary> 
        /// Occurs when an appointment is deleted. 
        /// </summary> 
        public event EventHandler AppointmentDelete; 
        #endregion 
        #region Event Handlers 
         
        protected void Page_Load( object sender, EventArgs e ) 
        { 
            if ( !IsPostBack ) 
            { 
                if ( FormLoad != null ) 
                { 
                    FormLoad( sender, e ); 
                } 
            } 
        } 
 
        protected void rscEvents_AppointmentInsert( object sender, SchedulerCancelEventArgs e ) 
        { 
            SetAppointmentDetails( e.Appointment ); 
 
            if ( AppointmentInsert != null ) 
            { 
                AppointmentInsert( sender, e ); 
            } 
        } 
 
        protected void rscEvents_AppointmentUpdate( object sender, AppointmentUpdateEventArgs e ) 
        { 
            SetAppointmentDetails( e.ModifiedAppointment ); 
 
            if ( AppointmentUpdate != null ) 
            { 
                AppointmentUpdate( sender, e ); 
            } 
        } 
 
        /// <summary> 
        /// The startDate is used to calculate the beginning date of the schedule 
        /// </summary> 
        protected void rscEvents_AppointmentDelete( object sender, SchedulerCancelEventArgs e ) 
        { 
            eventId = Int32.Parse( e.Appointment.ID.ToString() ); 
            startDate = e.Appointment.Start; 
 
            if ( AppointmentDelete != null ) 
            { 
                AppointmentDelete( sender, e ); 
            } 
        } 
 
        protected void rscEvents_AppointmentDataBound( object sender, SchedulerEventArgs e ) 
        { 
            e.Appointment.ToolTip = e.Appointment.Subject; 
        } 
 
        /// <summary> 
        /// Captures assynchronous exceptions and handles them in the same way as normal exceptions. 
        /// </summary> 
        protected void scmEvents_AsyncPostBackError( object sender, AsyncPostBackErrorEventArgs e ) 
        { 
            throw e.Exception; 
        } 
        
        #endregion 
        
        #region Properties 
         
        /// <summary> 
        /// This property is set by the Presenter when binding the scheduler control. 
        /// </summary> 
        public List<EventDTO> CurrentEvents 
        { 
            set 
            { 
                List<AppointmentDTO> appointments = new List<AppointmentDTO>(); 
 
                foreach ( EventDTO evnt in value ) 
                { 
                    appointments.Add( new AppointmentDTO( evnt ) ); 
                } 
 
                rscEvents.DataSource = appointments; 
                rscEvents.DataBind(); 
            } 
        } 
 
        public int EventId 
        { 
            get { return eventId; } 
        } 
 
        public string EventName 
        { 
            get { return eventName; } 
        } 
 
        public string EventDescription 
        { 
            get { return eventDescription; } 
        } 
 
        public DateTime StartDate 
        { 
            get { return startDate; } 
        } 
 
        public DateTime EndDate 
        { 
            get { return endDate; } 
        } 
 
        public string RecurrenceRule 
        { 
            get { return recurrenceRule; } 
        } 
 
        public string ReccurenceParentId 
        { 
            get { return recurrenceParentId; } 
        } 
        #endregion 
 
        /// <summary> 
        /// The fields being set in this method are used by the Presenter when saving appointments to the database. 
        /// </summary> 
        private void SetAppointmentDetails( Appointment appointment ) 
        { 
            eventId = appointment.ID != null ? Int32.Parse( appointment.ID.ToString() ) : -1; 
 
            eventName = appointment.Subject; 
            startDate = appointment.Start; 
            endDate = appointment.End; 
            recurrenceRule = appointment.RecurrenceRule; 
 
            if ( appointment.RecurrenceParentID != null && !String.IsNullOrEmpty( appointment.RecurrenceParentID.ToString() ) ) 
            { 
                recurrenceParentId = appointment.RecurrenceParentID.ToString(); 
            } 
        } 
        #region Classes 
 
        /// <summary> 
        /// Extends the base EventDTO to accomodate functionality in the Telerik Scheduler control by incorporating the RecurrenceState property and  
        /// making RecurrenceRule and RecurrenceParentId nullable. 
        /// </summary> 
        private class AppointmentDTO : EventDTO 
        { 
            #region Fields 
 
            private RecurrenceState recurrenceState; 
            #endregion 
            #region Constructors 
 
            private AppointmentDTO() 
            { 
                eventId = -1; 
            } 
 
            public AppointmentDTO( int eventId, string eventName, string eventDescription, DateTime startDate, DateTime endDate, string recurrenceRule, string recurrenceParentId ) : this() 
            { 
                this.eventId = eventId; 
                this.eventName = eventName; 
                this.eventDescription = eventDescription; 
                this.startDate = startDate; 
                this.endDate = endDate; 
                this.recurrenceRule = String.IsNullOrEmpty( recurrenceRule ) ? null : recurrenceRule; 
                this.recurrenceParentId = String.IsNullOrEmpty( recurrenceParentId ) ? null : recurrenceParentId; 
 
                if ( recurrenceParentId != null ) 
                { 
                    recurrenceState = RecurrenceState.Exception; 
                } 
                else if ( !String.IsNullOrEmpty( recurrenceRule ) ) 
                { 
                    recurrenceState = RecurrenceState.Occurence; 
                } 
            } 
 
            public AppointmentDTO( EventDTO evnt ) : this( evnt.EventId, evnt.EventName, evnt.EventDescription, evnt.StartDate, evnt.EndDate, evnt.RecurrenceRule, evnt.RecurrenceParentId ) { } 
            #endregion 
            #region Properties 
 
            /// <summary> 
            /// This is being setup as per the Binding Generic List demo but it never gets consumed - something I'm missing here??? 
            /// </summary> 
            public RecurrenceState RecurrenceState 
            { 
                get { return recurrenceState; } 
                set { recurrenceState = value; } 
            } 
            #endregion 
        } 
        #endregion 
    } 

I know that you can't see how the deletes, updates and inserts are actually being implemented because I haven't included the lower layers dealing with the business logic and data access but they are all working as they're supposed to.

Any help will be greatly appreciated. Thanks.
zac
Top achievements
Rank 1
 answered on 18 Jun 2008
3 answers
138 views
I looked at the online demos of this control, section: "Insert/Update/Delete" / "Edit on Double-Click".

I created a project just like that and replaced the Session Data Source with an asp:SqlDataSource.
The latter does not take the argument PrimaryKeyFields which is set to "OrderID,ProductID" in the original data source.
Because of this (I assume), I get the error...

Unable to update Orders. Reason: Must declare the variable '@OrderID'.

..when trying to update. I am using the Northwind SQL database I have made no changes in the select or update command. How do I use this control with an asp:SqlDataSource?
  
Daniel
Telerik team
 answered on 18 Jun 2008
6 answers
177 views
Hello telerik support team,

I have a problem with sorting if I bind an "interface list" to the radgrid. E.g. I have the following code:
AppUser.cs:
class AppUser : IAppUser
{
public string Account { get; set; }
    public string Password { get; set; }
}

Person.cs
class Person: IPerson
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

IAppUser.cs
public interface IAppUser : IPerson
{
string Account { get; set; }
string Password { get; set; }
}

IPerson.cs
public interface IPerson
{
    string FirstName { get; set; }
    string LastName { get; set; }
}

grid.aspx:
<asp:ScriptManager ID="scriptManager" runat="server"></asp:ScriptManager>
<telerik:RadGrid ID="dgAppuser" runat="server" AutoGenerateColumns="false" AllowSorting="true">
<MasterTableView AllowNaturalSort="false">
<Columns>
<telerik:GridBoundColumn HeaderText="Account" DataField="Account"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Password" DataField="Password"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="First Name" DataField="FirstName"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Last Name" DataField="LastName"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>

grid.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
dgAppuser.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(dgAppuser_NeedDataSource);
}
void dgAppuser_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
dgAppuser.DataSource = AppUser.GetAll();
}
The AppUser.GetAll() method returns an IList<IAppUser> object.
When I bind the list to the grid, the binding works, but if I try to sort by the property FirstName or LastName I get the following error:
IndexOutOfRangeException: Column LastName was not found.

If the GetAll() method returns IList<AppUser> instead of IList<IAppUser> the sorting is works.

Is there a solution for this problem or must I add all properties from the base interface also to the derived interface?

Thanks in advance.

Thomas Mayer
Rosen
Telerik team
 answered on 18 Jun 2008
2 answers
169 views
I need to create a custom button for the radeditor and could do with some support.

Basically I'm using the editor to write articles which need to be linked to each other. Rather than having to find the URL of each page the end user wants to link articles too, I need a way of displaying a list of the articles in a window which appears when you click the custom button.

The user could type '(see here)' then highlight the text, click on the button which opens up a dropdown list of all the articles. They then select an article and it automatically makes the link.

Is this is a possibility and how could I do this? Any working examples of something like this would be most appreciated.
Curt
Top achievements
Rank 1
 answered on 18 Jun 2008
1 answer
141 views
Hi,

We are having a strange error.

ScriptLoadFailedException.  The script /Telerik.Web.Ui.WebResource.axd..........

Missing call to Sys.Application.notifyScriptLoaded.

The error is only happening for specific users on our network in IE6.  On one machine the app works fine logged in as me but when logged in as someone with less permissions on the same machine we recieve the above message.

From my understanding it comes from either invalid JS or missing the below.

if( Sys && Sys.Application ){

Sys.Application.notifyScriptLoaded();

}

But..........


Why would this message be privelage specific??????  If it works for one user it should work for them both.

Has anybody experienced this before.

Thanks for any help.

Peter
Telerik team
 answered on 18 Jun 2008
1 answer
118 views
I see the documentation in the help file on implementing the radiobutton function in the RadTreeView control. That's great! Is there any way to actually display a radio button (instead of checkbox) for the control?

Thanks.
Veselin Vasilev
Telerik team
 answered on 18 Jun 2008
2 answers
116 views
hi. New to these controls but wondering if possible to somehow set a default telerik skin somewhere... ie the web.config or seperate class file.
I would like to be able to just use the ctrls without needing to set the skin each time. this seems contrary to logical UI development, where I would just change the css.
Sorry if this question seems to answer itself but I can't see the solution.
 
Please note I am not uber technical so samples are greatly, greatly appreciated.
thanks
mac
Top achievements
Rank 1
 answered on 18 Jun 2008
1 answer
121 views
Hello 

Its been almost 11/2 yr now i have been using Telerik Controls and its amazing
Do you support Controls which work on Iphone or any Mobile Web Application

If so can you send me some online demos

Thanks
Kavya
Vlad
Telerik team
 answered on 18 Jun 2008
1 answer
175 views
Hi
I am using radtooltipmanager loading with the usercontrol  files
I am opening the tooltip with click of the hyperlink
i am also using eworld controls which has masked textbox control
the problem is the eworld controls are not working when i use tooltipmanager

Instead i use to load the same controls in tooltip, in that case its working. But the controls are not working when i used to open the same page using tooltipmanager

I am struct up with this, it will be greatful if someone give any idea on this
Svetlina Anati
Telerik team
 answered on 18 Jun 2008
1 answer
203 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?