Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
311 views
Hello.

I have been developing a web application that accesses the database via web service.
In order to block time slots of the RadScheduler component, I have implemented the following method, which is associated with event OnTimeSlotCreated:
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
{     
    // checking if the current time slot is blocked
    if (TimeSlotBlocked(e.TimeSlot.Resource.Key.ToString(), e.TimeSlot.Start, e.TimeSlot.End))
    {
        e.TimeSlot.CssClass = "Disabled";            
    }                                 
}

Method TimeSlotBlock checks if the resource is blocked for the start and end times provided:
protected bool TimeSlotBlocked(String pt, DateTime dt1, DateTime dt2)
{
    foreach (PTBlockedTime bt in blockedTime)
    {
        if ((pt == bt.PersonalTrainerId) && ((dt1.AddMinutes(+1) >= bt.Start && dt1.AddMinutes(+1) <= bt.End) || (dt2.AddMinutes(-1) >= bt.Start && dt2.AddMinutes(-1) <= bt.End)))
        {
            return true;
        }
    }
    return false;
}

blockedTime is a list of blocked times:
public struct PTBlockedTime
{
    public String PersonalTrainerId;
    public DateTime Start;
    public DateTime End;
  
    public PTBlockedTime(String pt, DateTime dt1, DateTime dt2)
    {
        PersonalTrainerId = pt;
        Start = dt1;
        End = dt2;
    }
}
.
.
.
List<PTBlockedTime> blockedTime = new List<PTBlockedTime>();

For testing purposes, I have loaded blockedTime on Page_Load:
DateTime aux1 = new DateTime(2012, 1, 25, 8, 0, 0);
DateTime aux2 = new DateTime(2012, 1, 25, 10, 0, 0);
PTBlockedTime aux = new PTBlockedTime("575204", aux1, aux2);
blockedTime.Add(aux);
This list item indicates that resource "575204" is blocked from 08:00 AM to 10:00 AM on 01/25/2012.


This solution works only partially for two reasons:

1) Method TimeSlotCreated is not called when the calendar date changes. Although in the code above the resource is blocked only on 01/25/2012, all dates will have the time slots blocked from 8 to 10.
Is there a way to solve this problem?

2) Instead of Page_Load, the routine that populates the list of blocked times needs to be called every time the calendar date changes. This is required because the time resources are blocked varies on a daily basis. On one day, a resource might be blocked from 8 to 10 AM. On another day, from 5 to 7 AM. And in another day, not blocked at all.
How can the list of blocked times be populated every time the calendar date changes?

Thank you in advance.
Paulo

Plamen
Telerik team
 answered on 20 Feb 2012
34 answers
349 views
When I call the ExportToPdf() function for my scheduler widget, I get the following error. Anyone aware of what that could be?

System.ArgumentException: Parameter is not valid.
at System.Drawing.Bitmap..ctor(Stream stream)
at Telerik.Web.Apoc.Image.ApocImage..ctor(String href, Byte[] imageData)
at Telerik.Web.Apoc.Image.ApocImageFactory.Make(String href)
at Telerik.Web.Apoc.Fo.Flow.ExternalGraphic.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.SystemException: System.ArgumentException: Parameter is not valid.
at System.Drawing.Bitmap..ctor(Stream stream)
at Telerik.Web.Apoc.Image.ApocImage..ctor(String href, Byte[] imageData)
at Telerik.Web.Apoc.Image.ApocImageFactory.Make(String href)
at Telerik.Web.Apoc.Fo.Flow.ExternalGraphic.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)
Helen
Telerik team
 answered on 20 Feb 2012
4 answers
111 views
Hi

I am new to Telerik and I am working with the scheduler and want recurring appointments.
I am using the standard advanced insert and then hooking into the oninsert event and adding them to the database but I am only seeing the appointment once in the scheduler.
I have found in the forum about the \r\n for the new lines and have tried adding this but it doesn't seem to make any difference but can't seem to find anything else.

Can anyone see what I am doing wrong?

I am adding appointments like this:

protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
       {
           //add the new appointment to the db
 
           int? recurrentParentId = null;
           if (e.Appointment.RecurrenceParentID != null) recurrentParentId = (int)e.Appointment.RecurrenceParentID;
           AppointmentManager.AddUserAppointment(
               UserId,
               1,
               e.Appointment.Start,
               e.Appointment.End,
               e.Appointment.RecurrenceRule,
               recurrentParentId,
               e.Appointment.Description,
               e.Appointment.Subject);
           BindSchedule();
       }


I am then binding the scheduler like this:
mySchedule.DataSource = GetSchedule(); //calls the database and gets the appointments
mySchedule.DataBind();

This is my scheduler markup is:
<telerik:RadScheduler runat="server" ID="mySchedule" DayStartTime="08:00:00" DayEndTime="22:00:00"
    StartInsertingInAdvancedForm="true" ShowNavigationPane="true" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
    OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnAppointmentDelete="RadScheduler1_AppointmentDelete"
    DataKeyField="AppointmentId" DataSubjectField="Subject" DataDescriptionField="Description"
    DataStartField="Start" DataEndField="EndX" DataRecurrenceField="RecurrenceRule"
    DataRecurrenceParentKeyField="RecurrenceParentId" FirstDayOfWeek="Monday" ShowHeader="true"
    ShowFooter="false">
    <AdvancedForm Modal="true" />
    <DayView UserSelectable="false" />
    <WeekView UserSelectable="false" />
    <MonthView UserSelectable="false" />
    <TimeSlotContextMenuSettings EnableDefault="true" />
    <AppointmentContextMenuSettings EnableDefault="true" />
    <ResourceTypes>
        <telerik:ResourceType KeyField="ID" Name="Type" TextField="Keyword" ForeignKeyField="AppointmentTypeID"
            DataSourceID="AppointmentTypesDataSource" />
    </ResourceTypes>
    <ResourceStyles>
        <telerik:ResourceStyleMapping Type="Type" Text="Event" ApplyCssClass="rsCategoryGreen" />
                <telerik:ResourceStyleMapping Type="Type" Text="Personal" ApplyCssClass="rsCategoryBlue" />
        <telerik:ResourceStyleMapping Type="Type" Text="Meeting" ApplyCssClass="rsCategoryYellow" />
    </ResourceStyles>
    <AppointmentTemplate>
               <!--narrowed down template-->
        <div >
            <h2>
                <%# Eval("Subject") %>
            </h2>
            <div>
            </div>
        </div>
        
    </AppointmentTemplate>
</telerik:RadScheduler>

Bex
Bex
Top achievements
Rank 1
 answered on 20 Feb 2012
2 answers
243 views
I am having a hell of a time getting this to work correctly.  I have a RadWindow that can be launched from any site on the page (the link resides on a master page) and will bring up a login window.

When the user successfully logins in, the SQL reader will set a variable in session and then once the data reader has closed SHOULD redirect to a page based on what is stored in the session variable.

So I need to be able in my code behind to say If Session("ThisValue") = Something then Close RadWindow and redirect parent.

I have this code in the RadWindow:
    <script type="text/javascript">
        function RedirectUser(sender, args) {
            GetRadWindow().BrowserWindow.location.href = '../ThisPageWhenRedirectUser.aspx';
            GetRadWindow().close();       //closes the window    
        }
        function GetRadWindow()   //Get reference to window 
        {
            var oWindow = null;
            if (window.radWindow)
                oWindow = window.radWindow;
            else if (window.frameElement.radWindow)
                oWindow = window.frameElement.radWindow;
            return oWindow;
        }    
</script>

I just don't know how to call that from my code behind.  I am trying it like so:

'after database has retrieved and stored the value in session
If (Session("UserType") = Something Then CloseRadAndRedirect()
 
Public Sub CloseRadAndRedirect()
        If (Not ClientScript.IsStartupScriptRegistered("GetRadWindow")) Then
            ScriptManager.RegisterStartupScript(Page, Me.GetType(), "GetRadWindow", "RedirectUser();", True)
        End If
    End Sub

This does not work.  In fact it simply refreshes the radwindow and the controls lose their formatting and styles.

Any help would be greatly appreciated.
Marin Bratanov
Telerik team
 answered on 20 Feb 2012
1 answer
185 views
Hai friends,

We are using RadCalender in our application.
By default RadCalender displaying current month.
Our requirment is differ to this.

in our code we are having a variable selectDate(this variable contains date).
this selectDate may be less than current date or may be greater than the current date.

Now depending on the date ,we have to display respective month calender.
i.e
 if selectDate="24/2/2012"  ,then RadCalender has to display feb month
 if selectDate="24/3/2012"  ,then RadCalender has to display march month


Same requirement for RadScheduler also
 if selectDate="24/2/2012"  ,then RadScheduler has to display feb month
 if selectDate="24/3/2012"  ,then RadScheduler has to display march month


how can i do this

Thanks in advance
Anwar

Richard
Top achievements
Rank 1
 answered on 20 Feb 2012
3 answers
229 views
HI,

I need to add a RequiredFieldValidator to the grid. The columns are autogenerated. 
I was able to acess the column value in the InsertCommand untill I added the below code to the ItemDataBound.
How do I acess the columns in the InsertCommand?

Thanks for your help!!

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
 
       {
 
 if ((e.Item is GridEditableItem && e.Item.IsInEditMode))
 
           {
 
               GridEditableItem item = e.Item as GridEditableItem;
 
               GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor(Convert.ToString(ViewState["ColName"]));
 
               TableCell cell = (TableCell)editor.TextBoxControl.Parent;
 
  
 
               RequiredFieldValidator validator = new RequiredFieldValidator();
 
               editor.TextBoxControl.ID = "txtValue";
 
               validator.ControlToValidate = editor.TextBoxControl.ID;
 
               validator.ErrorMessage = "*";
 
               cell.Controls.Add(validator);
 
  
 
      
 
           }
 
       }
 
  
 
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
 
       {
 
           string tableName = rcbLkup.SelectedValue;
 
           GridDataInsertItem row = (GridDataInsertItem)e.Item;
 
  
 
           BLL_LkupMaintenance objLkup = new BLL_LkupMaintenance();
 
  
 
           objLkup.ColName = Convert.ToString(ViewState["ColName"]);
 
           //objLkup.LkupValue = row[objLkup.ColName].Text;
 
           objLkup.LkupValue = ((TextBox)row.Controls[4].Controls[0]).Text;
 
           objLkup.AddToLkupTable(tableName);
 
  
 
       }

<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
        CellSpacing="0" GridLines="None"
    onprerender="RadGrid1_PreRender" onupdatecommand="RadGrid1_UpdateCommand"
        oninsertcommand="RadGrid1_InsertCommand"
        onitemdatabound="RadGrid1_ItemDataBound" >
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
        <MasterTableView EditMode="InPlace" DataKeyNames="ID" CommandItemDisplay="Top" >
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column">
                </telerik:GridEditCommandColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>
Jagat
Top achievements
Rank 1
 answered on 20 Feb 2012
3 answers
214 views
hello,
i'm developing a web application that contains tabstrip control , multipage pageview controls,i have a button and through this button i want to navigate through tabs using ajax everything was working ok until i've added the prometheus editor in my page the following error was raised
The PageRequestManager cannot be initialized more than once."
this error is raised on "IE7" but in firefox it was running ok
i think the  cause of the problem from  asp:script manager as i've got the following warnings
Assuming assembly reference 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy        
 
please note that i'm using Rad ajax manager v 1.8.1.0,VS 2008 beta1
is there any way to solve this problem

Thank You
Ibrahim Imam

Rumen
Telerik team
 answered on 20 Feb 2012
1 answer
206 views
Hi, i am using rad editor in wysiwyg mode.

I need to insert some text to cursor position.

before paste some text, i need to check some condition like, the given cursor position is center/left/right of the particular elememt.

My code like
var selectedtag = editor.getSelectedElement();
                      var range = editor.getSelection().getRange();
                      var selection = editor.getSelection();
                      if (selectedtag.tagName != "LI" && selectedtag.tagName != "P") {
                          var sel = editor.getSelection().getText();
                          var text = selectedtag.innerHTML;
                          //range.pasteHTML('<p>' + sel + '</p>');
                           selectedtag.innerHTML = '<p>' + text;
                          
 
 
                      }
                      else if (selectedtag.tagName == "LI") {
                          var sel = editor.getSelection().getText();
                          if (sel == "") {
                              range.pasteHTML('</li><li>...</li>');
                          }
                          else {
                              range.pasteHTML('</li><li>' + sel + '</li>');
                          }
                      }
                      else if (selectedtag.tagName == "P") {
                          var sel = editor.getSelection().getText();
                          if (sel == "") {
                              range.pasteHTML('</p><p>');
                          }
                          else {
                              range.pasteHTML('</p><p>' + sel + '</p>');
                          }
                      }
                      else {
                          var sel = editor.getSelection().getText();
                          if (sel == "") {
                              range.pasteHTML('</p><p>');
                          }
                          else {
                              range.pasteHTML('</p><p>' + sel + '</p><p>');
                          }
                      }
i got the range.
But , how to check if the selected text has any text before and after.

I need to implement some text based on the condition like,

Te  Text to the left is empty (ie selection is at the start of the element): <p> selected text text to the right</p>

3)  Text to the right is empty (ie selection is at the end of the element): <p>Text to the left selected text </p>

i need the output like,

<p> selected text</p><p>text to the right</p>

How to check if the selected text /range contains any text before and after the selected text.

This is urgent requirement.
Thanks ,
Uma



Rumen
Telerik team
 answered on 20 Feb 2012
1 answer
51 views
I am interested in using Telerik RadSpell client side.  My specific need is that I want to be able to control the action performed on the replaced/corrected words.  Is there a way to bind to an event that will allow me to custom wrap the corrected word in some additional HTML?
 
Rumen
Telerik team
 answered on 20 Feb 2012
1 answer
112 views
Hi Telerik,

In one of my application,In one page i am using radeditor in that,i want to give more than 8000 characters.Is it possible or not?

Thanks in Advance.
Ur's
Sekhar
Rumen
Telerik team
 answered on 20 Feb 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?