More in this section

Forums / Developing with Sitefinity / WebEditor AutoSelect = True - How do you return the value back to the control?

WebEditor AutoSelect = True - How do you return the value back to the control?

3 posts, 0 answered
  1. TIOS
    TIOS avatar
    48 posts
    Registered:
    22 Mar 2006
    03 Apr 2009
    Link to this post
    Hi,

    I've got a WebEditor that's working as a none auto select perfectly:

    i.e.  Textbox on WebEditor and it returns it from where it came from.

    I've now modified the WebEditor to include a RadGrid and on the SelectedIndexChanged i'm doing:

            Dim strSelectedId As String = auctionsGrid.SelectedItems(0).OwnerTableView.DataKeyValues(auctionsGrid.SelectedItems(0).ItemIndex)("AuctionID").ToString
            Me.TextBox1.Text = strSelectedId

    I've set AutoSelect to return True, how do I get it to return the selectedvalue to the control when they press the rad grid select button?

    Thanks,
    Chris
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    06 Apr 2009
    Link to this post
    Hello Chris Bond,

    You need to fire the ValueChanged of your web editor after user have selected a row:

    Dim strSelectedId As String = auctionsGrid.SelectedItems(0).OwnerTableView.DataKeyValues(auctionsGrid.SelectedItems(0).ItemIndex)("AuctionID").ToString  
      
    Me.TextBox1.Text = strSelectedId  
      
    Dim eventArgs As New ValueChangedEventArgs(strSelectedId) 
    OnValueChanged(eventArgs) 
      

    The web editor will close automatically.

    Greetings,
    Parvan
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. TIOS
    TIOS avatar
    48 posts
    Registered:
    22 Mar 2006
    07 Apr 2009
    Link to this post
    Thanks that was helpful, after that i did a search and found the following thread helped but did not have the full answer.

    Because i'm building my WebEditor in a UserControl thing's are slightly different and ofcourse i'm a vb.net fan so things work different again!

    Incase other people are having issues please find some sample code that i've tested and works a dream.

    XSelectorWebEditor.ascx.vb:
    Imports System 
    Imports System.Web.UI 
    Imports Telerik.Cms.Web.UI 
     
    Partial Class XModule_WebEditors_AuctionSelectorWebEditor 
        Inherits System.Web.UI.UserControl 
        Implements IWebUITypeEditor 
     
        Private _hostControl As Control 
        Private _typeContainer As Object 
        Private _Value As Object 
     
        Public Property AutoSelect() As Boolean Implements Telerik.Cms.Web.UI.IWebUITypeEditor.AutoSelect 
            Get 
                Return True 
            End Get 
            Set(ByVal value As Boolean) 
            End Set 
        End Property 
     
        Public Sub EditValue(ByVal value As Object) Implements Telerik.Cms.Web.UI.IWebUITypeEditor.EditValue 
            _Value = value 
        End Sub 
     
        Public Function GetEditStyle() As System.Drawing.Design.UITypeEditorEditStyle Implements Telerik.Cms.Web.UI.IWebUITypeEditor.GetEditStyle 
            Return System.Drawing.Design.UITypeEditorEditStyle.Modal 
        End Function 
     
        Public Property HostControl() As System.Web.UI.Control Implements Telerik.Cms.Web.UI.IWebUITypeEditor.HostControl 
            Get 
                Return _hostControl 
            End Get 
            Set(ByVal value As System.Web.UI.Control) 
                _hostControl = value 
            End Set 
        End Property 
     
        Public ReadOnly Property Title() As String Implements Telerik.Cms.Web.UI.IWebUITypeEditor.Title 
            Get 
                Return "Please select an X" 
            End Get 
        End Property 
     
        Public Property TypeContainer() As Object Implements Telerik.Cms.Web.UI.IWebUITypeEditor.TypeContainer 
            Get 
                Return _typeContainer 
            End Get 
            Set(ByVal value As Object) 
                _typeContainer = value 
            End Set 
        End Property 
     
        Public Property Value() As Object Implements Telerik.Cms.Web.UI.IWebUITypeEditor.Value 
            Get 
                Return _Value 
            End Get 
            Set(ByVal value As Object) 
                _Value = value 
            End Set 
        End Property 
     
        Protected Overridable Sub OnValueChanged(ByVal e As ValueChangedEventArgs) 
            RaiseEvent ValueChanged(Me, e) 
        End Sub 
     
        Public Event ValueChanged(ByVal sender As Object, ByVal e As Telerik.Cms.Web.UI.ValueChangedEventArgs) Implements Telerik.Cms.Web.UI.IWebUITypeEditor.ValueChanged 
     
        Protected Sub XGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles XGrid.SelectedIndexChanged 
            Dim strSelectedId As String = XGrid.SelectedItems(0).OwnerTableView.DataKeyValues(XGrid.SelectedItems(0).ItemIndex)("MyID").ToString 
            _Value = strSelectedId 
            Dim eventArgs As New ValueChangedEventArgs(strSelectedId) 
            OnValueChanged(eventArgs) 
        End Sub 
    End Class 
     

Register for webinar
3 posts, 0 answered