Nannette Thacker ShiningStar.net

ASP.net Web Application Development

Sponsors

News

See all Blog Posts by Nannette.

Nannette Thacker, consultant and owner of Shining Star Services LLC, specializes in development of custom dynamic database driven web applications utilizing ASP.net technologies. Nannette has been developing ASP sites since 1997. Nannette has written numerous articles on web development techniques and tutorials.

Nannette is the owner and developer of ChristianSinglesDating.com.

 Subscribe in a reader





View Nannette  Thacker's profile on LinkedIn

Telerik VB Dynamic Data Field Templates - Decimal Edit - RadNumericTextBox

Here is a customFieldTemplate for Decimal Edit using VB and Telerik controls - RadNumericTextBox :

decimal_edit.ascx

 <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<telerik:RadNumericTextBox runat="server" ID="RadNumericTextBox1" Text='<%# FieldValueEditString %>' Skin="Vista"></telerik:RadNumericTextBox>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadNumericTextBox1" Display="Dynamic" Enabled="false" />
<asp:CompareValidator runat="server" ID="CompareValidator1" ControlToValidate="RadNumericTextBox1" Display="Dynamic"
    Operator="DataTypeCheck" Type="Double"/>
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1" ControlToValidate="RadNumericTextBox1" Display="Dynamic" Enabled="false" />
<asp:RangeValidator runat="server" ID="RangeValidator1" ControlToValidate="RadNumericTextBox1" Type="Double"
    Enabled="false" EnableClientScript="true" MinimumValue="0" MaximumValue="100" Display="Dynamic" />
<asp:DynamicValidator runat="server" ID="DynamicValidator1" ControlToValidate="RadNumericTextBox1" Display="Dynamic" />

decimal_edit.ascx.vb

Imports System.Web.DynamicData

Partial Class Decimal_EditField
    Inherits System.Web.DynamicData.FieldTemplateUserControl

       
    Public Overrides ReadOnly Property DataControl As Control
        Get
            Return RadNumericTextBox1
        End Get
    End Property
   
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Dim metaData = MetadataAttributes.OfType(Of System.ComponentModel.DataAnnotations.RangeAttribute)().FirstOrDefault()
        If Not IsDBNull(metaData) Then
            RadNumericTextBox1.MinValue = Convert.ToDouble(metaData.Minimum)
            RadNumericTextBox1.MaxValue = Convert.ToDouble(metaData.Maximum)
        End If

            RadNumericTextBox1.ToolTip = Column.Description
            SetUpValidator(RequiredFieldValidator1)
            SetUpValidator(CompareValidator1)
            SetUpValidator(RegularExpressionValidator1)
            SetUpValidator(RangeValidator1)
            SetUpValidator(DynamicValidator1)
    End Sub
   
    Protected Overrides Sub ExtractValues(ByVal dictionary As IOrderedDictionary)
        dictionary(Column.Name) = ConvertEditedValue(RadNumericTextBox1.Text)
    End Sub


End Class

For a C# version of Telerik field templates, see Atanas Korchev's blog, Yet another update of RadControls for ASP.NET Ajax DynamicData support.

 

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)