This is a migrated thread and some comments may be shown as answers.

Run Javascript Onblur of textbox

3 Answers 225 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 13 Aug 2009, 06:26 PM
I have four radtextboxes. On the fourth one, I want to call a JavaScript function. I need to get all four of the values of the textboxes to manipulate them. So far, I cannot get anything to fire on my onblur event. Anyone know why? Here is my code.

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/admin/Admin.Master"
    CodeBehind="AddBusiness.aspx.vb" Inherits="ClickableCommunity.AddBusiness" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        function getLatLon(street, city, state, zip) {
            alert(street + city + state + zip);
        }//getLatLong
        
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="header" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadTextBox ID="streetInput" runat="server" Label="Street">
    </telerik:RadTextBox>
    <telerik:RadTextBox ID="cityInput" runat="server" label="City">
    </telerik:RadTextBox>
    <telerik:RadTextBox ID="stateInput" runat="server" label="State">
    </telerik:RadTextBox>
    <telerik:RadTextBox ID="zipInput" runat="server">
        <ClientEvents OnBlur="getLatLon('<%= streetInput.ClientID %>',
                                        '<%= cityInput.ClientID %>',
                                        '<%= stateInput.ClientID %>',
                                        '<%= zipInput.ClientID %>')" />
    </telerik:RadTextBox>
</asp:Content>

3 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 14 Aug 2009, 06:48 AM
Hello,

Try the following approach:

    <telerik:RadTextBox ID="streetInput" runat="server" Label="Street">  
    </telerik:RadTextBox> 
    <telerik:RadTextBox ID="cityInput" runat="server" Label="City">  
    </telerik:RadTextBox> 
    <telerik:RadTextBox ID="stateInput" runat="server" Label="State">  
    </telerik:RadTextBox>      
      
    <telerik:RadScriptBlock ID="ScriptBlock1" runat="server">      
        <script type="text/javascript">          
            function getLatLon(sender, args)  
            {                      
                var streetInput = $find('<%= streetInput.ClientID %>');  
                var cityInput = $find('<%= cityInput.ClientID %>');  
                var stateInput = $find('<%= stateInput.ClientID %>');  
                var zipInput = $find('<%= zipInput.ClientID %>');              
            }          
        </script>      
    </telerik:RadScriptBlock> 
      
    <telerik:RadTextBox ID="zipInput" runat="server">  
        <ClientEvents OnBlur="getLatLon" /> 
    </telerik:RadTextBox> 

I hope this helps.

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Web Services
Top achievements
Rank 2
answered on 14 Aug 2009, 01:35 PM
Thanks for the reply I will check it out. I have noticed $find $get etc. Are those some built in functions for the rad controls or something? If so, is there some documentation on them somewhere. It kind of confused me when I saw them first. especially coming from PHP.
0
Paul
Telerik team
answered on 14 Aug 2009, 01:57 PM
Hi there,

$get can be used as shorthand for the document.getElementById and element.getElementById functions.  The $get shortcut function points to the Sys.UI.DomElement.getElementById JavaScript function which is defined as part of the ASP.NET AJAX client side library (which means you will need to include a ScriptManager on the page to be able to use it).  $get accepts two parameters, the first is the ID of the DOM element you want to retrieve, the second is the parent element of where the search starts.  The second parameter is optional and when it is not supplied defaults to the document element.  Here is the official API reference.

The $find shortcut function allows you to look up an ASP.NET AJAX client side Component by it's ID.  Here is a link to the $find shortcut's documentation and below is the API description.

All the best,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Web Services
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
Web Services
Top achievements
Rank 2
Paul
Telerik team
Share this question
or