RadTextBox Value

3 posts, 1 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 14 Aug 2009 Link to this post

    I have some JS functions that retrieve a latitude and longitude and set a couple radtextboxes to the value. The only problem is, they don't set these textboxes to the value until after you mouse into them. What happens is the user fills in address information. I then take that and parse it with google's gmap api to get a lat and lon. I set the textboxes value to those but it won't show up until you mouse into them. I need it to show as soon as it finds it. Here is my code
    <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/admin/Admin.Master"
        CodeBehind="AddBusiness.aspx.vb" Inherits="ClickableCommunity.AddBusiness" %>

    <%@ Register Assembly="RadMenu" Namespace="Telerik.WebControls" TagPrefix="radM" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <telerik:RadScriptBlock ID="ScriptBlock1" runat="server">
            <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAANvmC5YwARPSDAHoiTGyjXRR-496V5WiR7LkdzcFVQzFkDe07hhSkvWarTS8udi3TGEWMPQwT-FAGew"
            type="text/javascript"></script>
            <script type="text/javascript">
                function getLatLon(sender, args) {

                    var street = $find('<%= streetInput.ClientID %>').get_value();
                    var city = $find('<%= cityInput.ClientID %>').get_value();
                    var state = $find('<%= stateInput.ClientID %>').get_value();
                    var zip = $find('<%= zipInput.ClientID %>').get_value();
                    var address = (street + " " + city + ", " + state + " " + zip);

                    geocodeAddress(address);
                } //getLatLon

                //this function takes in an address and returns
                //the lattitude and longitude.
                function geocodeAddress(address) {
                    var coder = new GClientGeocoder();
                    coder.getLatLng(address,
                      function(point) {
                          if (!point) {
                              alert(address + " not found");
                          } //if

                          //we set the textboxes to their values
                          else {
                              //this is where it sets the rad textboxes values
                              //to set instantly but they only set when you mouse in
                              var templat = $get('<%= latInput.ClientID %>');
                              var templon = $get('<%= lonInput.ClientID %>');
                              templat.value = point.lat();
                              templon.value = point.lng();
                              
                          } //else
                      } //function(point)
                    );
                }//geocodeAddress           
            </script>

        </telerik:RadScriptBlock>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="header" runat="server">
    </asp:Content>
    <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
        <table cellpadding="30" width="350px">
            <tr>
                <td>
                    <span class="addBusinessLabel">Business Name</span>
                    <telerik:RadTextBox ID="businessNameInput" runat="server" Skin="Web20" Width="150px">
                    </telerik:RadTextBox>
                </td>
                <td>
                    <span class="addBusinessLabel">User</span>
                    <telerik:RadComboBox ID="RadComboBox2" runat="server" Skin="Web20" Width="150px">
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td>
                    <span class="addBusinessLabel">Street Address</span>
                    <telerik:RadTextBox ID="streetInput" runat="server" Skin="Web20" Width="150px">
                    </telerik:RadTextBox>
                </td>
                <td>
                    <span class="addBusinessLabel">City</span>
                    <telerik:RadTextBox ID="cityInput" runat="server" Skin="Web20" Width="150px">
                    </telerik:RadTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <center>
                        <span class="addBusinessLabel">State</span>
                        <telerik:RadComboBox ID="stateInput" runat="server" Skin="Web20" Width="150px" ChangeTextOnKeyBoardNavigation="true"
                            MarkFirstMatch="true" DropDownWidth="150px">
                            <Items>
                                <telerik:RadComboBoxItem Text="Alabama" Value="AL" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Alaska" Value="AK" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Arizona" Value="AZ" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Arkansas" Value="AR" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="California" Value="CA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Colorado" Value="CO" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Connecticut" Value="CT" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Delaware" Value="DE" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="District Of Columbia" Value="DC" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Florida" Value="FL" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Georgia" Value="GA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Hawaii" Value="HI" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Idaho" Value="ID" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Illinois" Value="IL" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Indiana" Value="IN" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Iowa" Value="IA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Kansas" Value="KS" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Kentucky" Value="KY" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Louisiana" Value="LA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Maine" Value="ME" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Maryland" Value="MD" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Massachusetts" Value="MA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Michigan" Value="MI" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Minnesota" Value="MN" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Mississippi" Value="MS" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Missouri" Value="MO" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Montana" Value="MT" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Nebraska" Value="NE" CssClass="stateDropDownText" Selected="true" />
                                <telerik:RadComboBoxItem Text="Nevada" Value="NV" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="New Hampshire" Value="NH" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="New Jersey" Value="NJ" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="New Mexico" Value="NM" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="New York" Value="NY" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="North Carolina" Value="NC" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="North Dakota" Value="ND" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Ohio" Value="OH" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Oklahoma" Value="OK" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Oregon" Value="OR" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Pennsylvania" Value="PA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Rhode Island" Value="RI" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="South Carolina" Value="SC" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="South Dakota" Value="SD" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Tennessee" Value="TN" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Texas" Value="TX" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Utah" Value="UT" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Vermont" Value="VT" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Virginia" Value="VA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Washington" Value="WA" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="West Virginia" Value="WV" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Wisconsin" Value="WI" CssClass="stateDropDownText" />
                                <telerik:RadComboBoxItem Text="Wyoming" Value="WY" CssClass="stateDropDownText" />
                            </Items>
                        </telerik:RadComboBox>
                    </center>
                </td>
                <td>
                    <span class="addBusinessLabel">Zip</span> <span style="width: 150px">
                        <telerik:RadTextBox ID="zipInput" runat="server" Skin="Web20" Width="150px">
                            <ClientEvents OnBlur="getLatLon" />
                        </telerik:RadTextBox>
                    </span>
                </td>
            </tr>
            <tr>
                <td>
                    <span class="addBusinessLabel">Latitude</span>
                    <telerik:RadTextBox ID="latInput" runat="server" Skin="Web20" Width="150px">
                    </telerik:RadTextBox>
                </td>
                <td>
                    <span class="addBusinessLabel">Longitude</span>
                    <telerik:RadTextBox ID="lonInput" runat="server" Skin="Web20" Width="150px">
                    </telerik:RadTextBox>
                </td>
            </tr>
        </table>
    </asp:Content>
    Thanks,
  2. Answer
    Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 17 Aug 2009 Link to this post

    Hi,

    To make it work you should set the values of the RadInput controls through the client-side API, similar to the following:

    var templat = $find('<%= latInput.ClientID %>'); 
    var templon = $find('<%= lonInput.ClientID %>'); 
    templat.set_value() = point.lat(); 
    templon.set_value() = point.lng(); 

    Greetings,
    Pavel
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 17 Aug 2009 Link to this post

    That did it thanks.
Back to Top