Accessing controls from code behind

2 posts, 0 answers
  1. dimis vasalos
    dimis vasalos avatar
    4 posts
    Member since:
    Nov 2009

    Posted 18 Jun 2011 Link to this post

    Dear sirs

    I have added 4 new resource types Task,Client,Infotype,Status
    Im facing 2 problems
    1. I could not access these controls from codebehind
    below im given you a sample of finding <Task> the dd_combo return nothing the same happens if i try to find the other 4
    resources <client,infotype,status>
    2. I will like to know how can i handle advancedform validation for these 4 new resources when user press the save button, i have tried all javascript sample you provided in forums with no luck

    CodeBehind
    '=======================================================================================
    Protected
    Sub rs_FormCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerFormCreatedEventArgs) Handles rs.FormCreated

     

     

    If ((e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) _

     

     

    OrElse (e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.AdvancedInsert)) Then

     

     

     

     

     

     

    Dim ddl_combo As radcombobox= DirectCast(e.Container.FindControl("task"), radcombobox)

     

     

     

     

     

     

    End If

     

     

     

     

     

     

    end Sub
    '==========================================================================================

     

     

     


    '===========================================================================================
    <

     

    telerik:RadScheduler runat="server" ID="rs" SelectedDate="2007/03/30"

     

     

    TimeZoneOffset="03:00:00" StartEditingInAdvancedForm="true"

     

     

    CustomAttributeNames="StatusID,Task"

     

     

    StartInsertingInAdvancedForm="true" Width="100%" Height="500px"

     

     

    DataKeyField="ID" DataSubjectField="Subject" DataStartField="Start" DataEndField="End"

     

     

    DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"

     

     

    Culture="Greek (Greece)" EditFormDateFormat="dd/MM/yy" Skin="Office2007">

     

     

    <AdvancedForm Modal="True" DateFormat="dd/MM/yy"/>

     

     

    <AppointmentTemplate>

     

    <%

    # Eval("Subject")%>

     

     

     

    </AppointmentTemplate>

     

     

     

    <ResourceTypes>

     

     

    <telerik:ResourceType KeyField="taskID" Name="Task" TextField="descr" ForeignKeyField="taskid"

     

     

    DataSourceID="taskds" />

     

     

    <telerik:ResourceType KeyField="ID" Name="Client" TextField="UserName" ForeignKeyField="UserID"

     

     

    DataSourceID="usersds" />

     

     

    <telerik:ResourceType KeyField="informID" Name="InfoType" TextField="descr" ForeignKeyField="informid"

     

     

    DataSourceID="informds" />

     

     

    <telerik:ResourceType KeyField="StatusID" Name="Status" TextField="descr" ForeignKeyField="StatusID"

     

     

    DataSourceID="statusds" />

     

     

    </ResourceTypes>

     

     

     

    <TimeSlotContextMenuSettings EnableDefault="True" />

     

     

    <AppointmentContextMenuSettings EnableDefault="True" />

     

     

    </telerik:RadScheduler>
    '===================================================================================

     

  2. Plamen
    Admin
    Plamen avatar
    2959 posts

    Posted 22 Jun 2011 Link to this post

    Hello,

    We inspected your code and it seems that the ID in the FindControl method should be different- "Restask" instead of just "task':

    Dim scheduler As RadScheduler = TryCast(sender, RadScheduler)
    Dim co As RadComboBox = TryCast(e.Container.FindControl("ResRoom"), RadComboBox)

    Regarding the validation issue here is a sample code:

    Protected Sub RadScheduler1_AppointmentInsert(sender As Object, e As AppointmentInsertEventArgs)
        If e.Appointment.Resources.GetResourceByType("Room") Is Nothing Then
            Response.Write("No Room are selected" + "</br>")
            e.Cancel = True
        Else
            Response.Write("count:" + e.Appointment.Resources.Count + "</br>")
        End If
        If e.Appointment.Resources.GetResourceByType("User") Is Nothing Then
            Response.Write("No User are selected" + "</br>")
            e.Cancel = True
        Else
            Response.Write("count:" + e.Appointment.Resources.Count + "</br>")
        End If
    End Sub

    Please, take a look at this demo how to implement the validation. Notice that you have to implement the AppointmentUpdate as well.

    Greetings,
    Plamen Zdravkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top