Setting Attributes on a RadDateInput for use on client-side?

3 posts, 0 answers
  1. Scott
    Scott avatar
    11 posts
    Member since:
    Oct 2008

    Posted 01 Nov 2008 Link to this post

    Howdy, y'all.  I'm sure I'm missing something really basic, here.  I'm trying to write some additional information to the client-side attributes for a raddateinput control.  (This is part of a larger project, writing a custom validator, etc).  I've simplified out to a basic web page illustrating my challenge.  Here's my ASPX:

    <%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="test5.aspx.cs" Inherits="TASDashboard.Secured.test5" %> 
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
    <%@ Register assembly="Controls" namespace="TASDashboard" tagprefix="cc1" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
    <html xmlns="">  
    <head id="Head1" runat="server">  
        <title>Untitled Page</title> 
    <form runat="server">  
    <script language="javascript" type="text/javascript">  
        function testFunction(sender, args) {  
            alert(sender.testAttribute); //shows as undefined  
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
            <telerik:RadDateInput ID="RadDateInput1" Runat="server" DateFormat="HHmm"   
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" /> 
            <asp:Button ID="Button1" runat="server" Text="Button" /> 

    and here's my C#:


    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    namespace TASDashboard.Secured  
        public partial class test5 : DashboardBasePage  
            protected void Page_Load(object sender, EventArgs e)  
                RadDateInput1.ClientEvents.OnValueChanged = "testFunction";  

    And when I run it, and change the value of the raddateinput control, my javascript routine runs as expected, but sender.testAttribute is undefined.  Should I be looking somewhere else for testAttribute?

    Thank you!
  2. Vlad
    Vlad avatar
    11100 posts

    Posted 03 Nov 2008 Link to this post

    Hello Scott,

    Generally sender is the instance of the JavaScript object - you can try sender.get_element() instead!

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Scott
    Scott avatar
    11 posts
    Member since:
    Oct 2008

    Posted 03 Nov 2008 Link to this post

    Vlad -

    Thank you.  That was ALMOST it.  (I'd forgotten how useful the IE Developer toolbar can be in times like this.)  Just for anyone else reading this later - it looks like there are three INPUT elements within a span, for each RadDateInput:


    get_element() gets me RadDateInput1, but the attribute was on the _text.  So my final javascript that goes with the example I posted is:

    <script language="javascript" type="text/javascript">  
        function testFunction(sender, args) {  
            var elem = sender.get_element();  
            var attributedElem = document.getElementById( + '_text');  
            alert(attributedElem.testAttribute); //shows as hello  

    Thanks again,
Back to Top