Imports System
Imports System.ComponentModel
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebControls
Imports Telerik.Web.UI

<ToolboxItemAttribute(False)> _
Public Class Survey_FrontEnd
    Inherits WebPart

    ' Der Pfad wird unter Umständen automatisch aktualisiert, wenn das Visual WebPart-Projektelement geändert wird.
    Private Const _ascxPath As String = "~/_CONTROLTEMPLATES/Market_Survey_Tool_2011/Survey_FrontEnd/Survey_FrontEndUserControl.ascx"

    Private p_Country As String

    <System.Web.UI.WebControls.WebParts.WebBrowsable(True), System.Web.UI.WebControls.WebParts.WebDisplayName("Country"), System.Web.UI.WebControls.WebParts.WebDescription(""), System.Web.UI.WebControls.WebParts.Personalizable(System.Web.UI.WebControls.WebParts.PersonalizationScope.[Shared]), System.ComponentModel.Category("Settings"), System.ComponentModel.DefaultValue("")> _
    Public Property Country() As String
        Get
            Return p_Country
        End Get
        Set(ByVal value As String)
            p_Country = value
        End Set
    End Property

    Protected Overrides Sub CreateChildControls()
        Dim MyUserControl As Survey_FrontEndUserControl = DirectCast(Me.Page.LoadControl(_ascxPath), Survey_FrontEndUserControl)

        MyUserControl.Country = p_Country

        Controls.Add(MyUserControl)


        Dim panel As Panel = TryCast(MyUserControl.FindControl("panel1"), Panel)
        Dim loadingPanel As RadAjaxLoadingPanel = TryCast(MyUserControl.FindControl("RadAjaxLoadingPanel1"), RadAjaxLoadingPanel)

        AjaxManager.AjaxSettings.AddAjaxSetting(panel, panel, loadingPanel)

        MyBase.CreateChildControls()
    End Sub

    Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)
        MyBase.RenderContents(writer)
    End Sub

    Protected Overrides Sub OnInit(ByVal e As EventArgs)
        MyBase.OnInit(e)

        SetUpAjaxManagerOnPage()

        EnsureChildControls()
    End Sub


    Protected Sub SetUpAjaxManagerOnPage()
        Dim currentAjaxManager As RadAjaxManager = RadAjaxManager.GetCurrent(Page)

        If currentAjaxManager Is Nothing Then
            Page.Form.Controls.AddAt(0, AjaxManager)
            Page.Items.Add(GetType(RadAjaxManager), AjaxManager)
        End If
    End Sub

    Private _ajaxManager As RadAjaxManager
    Protected Overridable ReadOnly Property AjaxManager() As RadAjaxManager
        Get
            If _ajaxManager Is Nothing Then
                _ajaxManager = RadAjaxManager.GetCurrent(Page)

                If _ajaxManager Is Nothing Then
                    _ajaxManager = New RadAjaxManager() With { _
                     .ID = "RadAjaxManager1" _
                    }
                End If
            End If

            Return _ajaxManager
        End Get
    End Property



End Class
