I have a tooltip right above an asp button that I would like to use as a notification when an update is successful. However, I set the toolTip.visible to true and the tooltip never shows. Any ideas why? Here is my aspx
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/admin/Admin.Master"
CodeBehind="EditEntity.aspx.vb" Inherits="ClickableCommunity.EditEntity" %>
<%@ 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&v=2&sensor=false&key=ABQIAAAANvmC5YwARPSDAHoiTGyjXRSmfv2uK-bEd6eXTQY7EyaTpVn3FxSr013tT5OlQzrX6y2uOmRLFFdYTw"
type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
globalLat = 40.7001;
globalLon = -99.0844;
function map_initialize() {
//if the browser is compatible with the gmap api
if (GBrowserIsCompatible()) {
//initialize the map
map = new GMap2(document.getElementById('entityMap'));
//add the controls
map.addControl(new GLargeMapControl());
map.addControl(new GMenuMapTypeControl());
map.setCenter(new GLatLng(globalLat, globalLon), 15);
//enable the zooming
map.enableDoubleClickZoom();
map.enableScrollWheelZoom();
//add the marker and set the drag to true
globalMarker = new GMarker(map.getCenter(), { draggable: true });
//these should get the object of the rad textbox
var templat = $find('<%= latInput.ClientID %>');
var templon = $find('<%= lonInput.ClientID %>');
//if they drag the marker
GEvent.addListener(globalMarker, 'dragend',
function(p) {
map.panTo(p);
//set the textboxes to the latitude and long
templat.set_value(map.getCenter().lat().toFixed(6));
templon.set_value(map.getCenter().lng().toFixed(6));
} //function(p)
); //GEvent.addListener
//add the marker
map.addOverlay(globalMarker);
//add the geocoder
geocoder = new GClientGeocoder();
} //if gbrowsercompatible
} //map_initialize
function map_geocode(address) {
geocoder.getLatLng(address,
function(p) {
if (p) {
map.panTo(p);
} //if (p)
else {
alert('Sorry, the geocoder failed to locate the specified address :-(');
} //else
} //function
); //geocoder.getLatLng
} //map_geocode
GEvent.addDomListener(window, 'load', map_initialize);
//this function will get the latitude and longitude
//for a given address and set a tool tip to visible
//if it can't find the address.
function getLatLon(sender, args) {
//we only do something if the over ride button
//is not checked
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 + " " + 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) {
//the id of the tool tip
var toolTip = $find("<%= cantFindLocation.ClientID %>");
if (!point) {
//show the tool tip if it is hidden
if (!toolTip.isVisible()) {
toolTip.show();
} //if
//the tool tip is showing and the clicked the link
else {
toolTip.set_text("Still no dice, <a href=\"#\" onclick=\"getLatLon()\">" +
"try again</a> or get them <a href=\"" +
"http://itouchmap.com/latlong.html\" target=\"_blank\"" +
">manually</a>.");
} //else
} //if
//we set the textboxes to their values
else {
//reset the global lat and long
//and call the function to reload
//the map
var templat = $find('<%= latInput.ClientID %>');
var templon = $find('<%= lonInput.ClientID %>');
templat.set_value(point.lat());
templon.set_value(point.lng());
globalLat = point.lat();
globalLon = point.lng();
map_initialize();
//hide the tooltip if its showing
if (toolTip.isVisible()) {
toolTip.hide();
}
} //else
} //function(point)
);
} //geocodeAddress
</script>
</telerik:RadScriptBlock>
<style type="text/css">
.radfdSkinnedFormButton radfd_Web20
{
text-align: center !important;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="header" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<telerik:RadFormDecorator ID="decorator" Skin="Web20" DecoratedControls="Buttons"
runat="server" />
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<table class="entityTable">
<tr>
<td width="410px">
<table>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Select Entity</span>
<telerik:RadComboBox ID="businessNameDrop" runat="server" Skin="Web20" Width="150px"
MarkFirstMatch="True" DropDownWidth="150px" CssClass="stateDropDownText" Font-Size="16px"
AutoPostBack="true">
<CollapseAnimation Duration="1000" Type="InOutBack" />
</telerik:RadComboBox>
<asp:SqlDataSource ID="businessDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="getAllBusinesses" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Entity Name</span>
<telerik:RadTextBox ID="entityNameInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Category</span>
<telerik:RadComboBox ID="categoryDrop" runat="server" Skin="Web20" Width="150px"
MarkFirstMatch="True" DropDownWidth="150px" CssClass="stateDropDownText" Font-Size="16px"
DataSourceID="categoriesDataSource" DataTextField="name" DataValueField="categoryid">
<CollapseAnimation Duration="1000" Type="InOutBack" />
</telerik:RadComboBox>
<asp:SqlDataSource ID="categoriesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="getAllAttractionCategories" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td>
<span class="adminTableLabel">Description</span>
<center>
<table>
<tr>
<td>
<telerik:RadTextBox ID="descInput" runat="server" Skin="Web20" Height="150px" Width="150px"
Wrap="true" TextMode="MultiLine">
</telerik:RadTextBox>
</td>
</tr>
</table>
</center>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Street Address</span>
<telerik:RadTextBox ID="streetInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">City</span>
<telerik:RadTextBox ID="cityInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="tableColumn">
<telerik:RadToolTip runat="server" ID="overRideTip" Skin="Web20" Height="60px" Width="250px"
Position="TopRight" RelativeTo="Element" TargetControlID="overRide" AutoCloseDelay="5000"
IsClientID="true">
<span class="normalText">Check this if you would like to enter the latitude and longitude
manually.</span>
</telerik:RadToolTip>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">State</span>
<telerik:RadComboBox ID="stateInput" runat="server" Skin="Web20" Width="150px" ChangeTextOnKeyBoardNavigation="true"
MarkFirstMatch="true" DropDownWidth="150px" CssClass="stateDropDownText" Font-Size="16px">
<CollapseAnimation Duration="1000" Type="InOutBack" />
<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 class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Zip</span>
<telerik:RadTextBox ID="zipInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
<asp:RegularExpressionValidator ID="reZipCode" ControlToValidate="zipInput" ValidationExpression="^((\d{5}){1}|^(\d{5}-\d{4}){1}){1}"
ErrorMessage="Please enter a valid zip code." Display="Dynamic" runat="server"
CssClass="errorMessage" />
<telerik:RadToolTip runat="server" ID="cantFindLocation" Skin="Web20" Height="100px"
Width="400px" ManualClose="true" Position="TopRight" RelativeTo="Element" TargetControlID="streetInput">
<span class="normalText">I can't find the address you specified. Please make sure that
it is typed in correctly. If you would like to manually find the latitude and longitude,
go to <a href="http://itouchmap.com/latlong.html" target="_blank">here</a> and get
the coordinates. <a href="#" onclick="getLatLon()">Look Again</a> </span>
</telerik:RadToolTip>
</center>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Latitude</span>
<telerik:RadTextBox ID="latInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Longitude</span>
<telerik:RadTextBox ID="lonInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="tableColumn">
<a href="#" onclick="getLatLon()" style="font-size: 11px; font-family: Arial;">Find
on map </a>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Website</span>
<telerik:RadTextBox ID="siteInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Phone Number</span>
<telerik:RadTextBox ID="phoneInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
</tr>
</table>
<table>
<tr>
<td>
<table style="margin-left: 140px">
<tr>
<td>
<telerik:RadToolTip ID="toolTip" Skin="Web20"
Position="TopRight" runat="server" Height="100" Width="300"
RelativeTo="Element" HideDelay="25"
TargetControlID="addEntity" VisibleOnPageLoad="false">
</telerik:RadToolTip>
<asp:Button ID="addEntity" runat="server" Text="Change" /><br />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<center>
<asp:Label ID="output" runat="server" Text=""></asp:Label></center>
</td>
</tr>
</table>
</td>
<td class="entityMapClass">
<div id="entityMap">
</div>
</td>
</tr>
</table>
<asp:SqlDataSource ID="usersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="returnAllNonAdminUsers" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
<asp:Label Style="visibility: hidden;" ID="hiddenJs" runat="server" Text=""></asp:Label>
</telerik:RadAjaxPanel>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" SkinID="Web20"
Height="75px" Transparency="10" BackgroundPosition="Center">
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.LoadingProgressBar.gif") %>'
style="border: 0px;" />
</telerik:RadAjaxLoadingPanel>
</asp:Content>
And here is my vb
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Partial Public Class EditEntity
Inherits System.Web.UI.Page
'my connection string
Dim conn As String = System.Configuration.ConfigurationManager.ConnectionStrings("connectionString").ToString
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'populate the dropdown
Dim tableOfData As DataTable = createTable()
businessNameDrop.DataSource = tableOfData
businessNameDrop.DataTextField = "text"
businessNameDrop.DataValueField = "id"
businessNameDrop.DataBind()
End Sub
'this fires when they change the business name drop down box
Private Sub businessNameDrop_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles businessNameDrop.SelectedIndexChanged
If (businessNameDrop.Text <> "- Please Select -") Then
'the id
Dim entityId As Integer = businessNameDrop.SelectedValue
'set the entity name to the name
entityNameInput.Text = businessNameDrop.SelectedItem.Text
'my sql connection
Dim myConn As New Data.SqlClient.SqlConnection(conn)
'the name of the stored procedure
Dim strSQL = "getEntityInfo"
Dim returnCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)
'add the parameters
returnCommand.Parameters.AddWithValue("@entityId", entityId)
'tell the system it is a stored procedure
returnCommand.CommandType = CommandType.StoredProcedure
Try
myConn.Open()
Dim dr As SqlDataReader = returnCommand.ExecuteReader()
While dr.Read()
'set all of the textboxes to the input
streetInput.Text = dr.Item(0).ToString
cityInput.Text = dr.Item(1).ToString
stateInput.SelectedValue = dr.Item(2).ToString
zipInput.Text = dr.Item(3).ToString
latInput.Text = dr.Item(4).ToString
lonInput.Text = dr.Item(5).ToString
phoneInput.Text = dr.Item(6).ToString
siteInput.Text = dr.Item(7).ToString
descInput.Text = dr.Item(8).ToString
categoryDrop.SelectedValue = dr.Item(9)
End While 'while dr.read()
Catch ex As Exception
output.Text = ("<span class='textRed'>There was an error in retrieving the entity information,<br>" & _
" please contact the system administrator if the problem persists.</span>")
End Try
End If 'if businessNameDrop.text
End Sub
'if they click the add button
Protected Sub addEntity_Click(ByVal sender As Object, ByVal e As EventArgs) Handles AddEntity.Click
'a boolean if the form submission was successful
Dim success As Boolean = True
'all of the user input
Dim entityId As Integer = businessNameDrop.SelectedValue
Dim entityName As String = entityNameInput.Text
Dim street As String = streetInput.Text
Dim city As String = cityInput.Text
Dim state As String = stateInput.SelectedValue
Dim website As String = siteInput.Text
Dim phone As String = phoneInput.Text
Dim zip As Integer = CInt(zipInput.Text)
Dim lat As String = CDbl(latInput.Text)
Dim lon As String = CDbl(lonInput.Text)
Dim fkCatId As Integer = categoryDrop.SelectedValue
Dim desc As String = descInput.Text
'my sql connection
Dim myConn As New Data.SqlClient.SqlConnection(conn)
'the name of the stored procedure
Dim strSQL = "updateEntity"
Dim insertCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)
'add all of the parameters
insertCommand.Parameters.AddWithValue("@entityId", entityId)
insertCommand.Parameters.AddWithValue("@entityName", entityName)
insertCommand.Parameters.AddWithValue("@street", street)
insertCommand.Parameters.AddWithValue("@city", city)
insertCommand.Parameters.AddWithValue("@state", state)
insertCommand.Parameters.AddWithValue("@zip", zip)
insertCommand.Parameters.AddWithValue("@lat", lat)
insertCommand.Parameters.AddWithValue("@lon", lon)
insertCommand.Parameters.AddWithValue("@phone", phone)
insertCommand.Parameters.AddWithValue("@website", website)
insertCommand.Parameters.AddWithValue("@desc", desc)
insertCommand.Parameters.AddWithValue("@fkCatId", fkCatId)
'tell the system its a stored procedure
insertCommand.CommandType = CommandType.StoredProcedure
Try
myConn.Open()
insertCommand.ExecuteNonQuery()
Catch ex As Exception
toolTip.Text = "<span style='color:red;'>There was an error in adding the Place.<br>" & _
"Please contact the system administrator if the problem persists. "
'output.Text = ex.ToString
toolTip.Visible = True
success = False
Finally
myConn.Close()
End Try
If (success) Then
toolTip.Visible = True
toolTip.Text = "<span class='successText'>The entity was successfully updated.</span>"
End If
End Sub
'this sub returns a data table to bind to the dropdown
Private Function createTable()
'a new data table
Dim table As DataTable = New DataTable()
table.Columns.Add("id")
table.Columns.Add("text")
'my sql connection
Dim myConn As New Data.SqlClient.SqlConnection(conn)
'the name of the stored procedure
Dim strSQL = "getAllBusinesses"
'add the initial - Please Select -
table.Rows.Add(New String() {"-1", "- Please Select -"})
Try
myConn.Open()
Dim readCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)
'while we have rows from the stored procedure
'we will add them to a data table
Dim cdr As SqlDataReader = readCommand.ExecuteReader()
While cdr.Read()
If (cdr.Item(0).ToString <> "") Then
table.Rows.Add(New String() {cdr.Item(0), cdr.Item(1)})
End If
End While 'while cdr.Read()
Catch ex As Exception
output.Text = "There was an internal error. Please reload the page.<br>" & _
"If the problem persists, contact the system administrator"
End Try
myConn.Close()
Return table
End Function 'createTable
End Class
Thanks,
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/admin/Admin.Master"
CodeBehind="EditEntity.aspx.vb" Inherits="ClickableCommunity.EditEntity" %>
<%@ 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&v=2&sensor=false&key=ABQIAAAANvmC5YwARPSDAHoiTGyjXRSmfv2uK-bEd6eXTQY7EyaTpVn3FxSr013tT5OlQzrX6y2uOmRLFFdYTw"
type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
globalLat = 40.7001;
globalLon = -99.0844;
function map_initialize() {
//if the browser is compatible with the gmap api
if (GBrowserIsCompatible()) {
//initialize the map
map = new GMap2(document.getElementById('entityMap'));
//add the controls
map.addControl(new GLargeMapControl());
map.addControl(new GMenuMapTypeControl());
map.setCenter(new GLatLng(globalLat, globalLon), 15);
//enable the zooming
map.enableDoubleClickZoom();
map.enableScrollWheelZoom();
//add the marker and set the drag to true
globalMarker = new GMarker(map.getCenter(), { draggable: true });
//these should get the object of the rad textbox
var templat = $find('<%= latInput.ClientID %>');
var templon = $find('<%= lonInput.ClientID %>');
//if they drag the marker
GEvent.addListener(globalMarker, 'dragend',
function(p) {
map.panTo(p);
//set the textboxes to the latitude and long
templat.set_value(map.getCenter().lat().toFixed(6));
templon.set_value(map.getCenter().lng().toFixed(6));
} //function(p)
); //GEvent.addListener
//add the marker
map.addOverlay(globalMarker);
//add the geocoder
geocoder = new GClientGeocoder();
} //if gbrowsercompatible
} //map_initialize
function map_geocode(address) {
geocoder.getLatLng(address,
function(p) {
if (p) {
map.panTo(p);
} //if (p)
else {
alert('Sorry, the geocoder failed to locate the specified address :-(');
} //else
} //function
); //geocoder.getLatLng
} //map_geocode
GEvent.addDomListener(window, 'load', map_initialize);
//this function will get the latitude and longitude
//for a given address and set a tool tip to visible
//if it can't find the address.
function getLatLon(sender, args) {
//we only do something if the over ride button
//is not checked
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 + " " + 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) {
//the id of the tool tip
var toolTip = $find("<%= cantFindLocation.ClientID %>");
if (!point) {
//show the tool tip if it is hidden
if (!toolTip.isVisible()) {
toolTip.show();
} //if
//the tool tip is showing and the clicked the link
else {
toolTip.set_text("Still no dice, <a href=\"#\" onclick=\"getLatLon()\">" +
"try again</a> or get them <a href=\"" +
"http://itouchmap.com/latlong.html\" target=\"_blank\"" +
">manually</a>.");
} //else
} //if
//we set the textboxes to their values
else {
//reset the global lat and long
//and call the function to reload
//the map
var templat = $find('<%= latInput.ClientID %>');
var templon = $find('<%= lonInput.ClientID %>');
templat.set_value(point.lat());
templon.set_value(point.lng());
globalLat = point.lat();
globalLon = point.lng();
map_initialize();
//hide the tooltip if its showing
if (toolTip.isVisible()) {
toolTip.hide();
}
} //else
} //function(point)
);
} //geocodeAddress
</script>
</telerik:RadScriptBlock>
<style type="text/css">
.radfdSkinnedFormButton radfd_Web20
{
text-align: center !important;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="header" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<telerik:RadFormDecorator ID="decorator" Skin="Web20" DecoratedControls="Buttons"
runat="server" />
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<table class="entityTable">
<tr>
<td width="410px">
<table>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Select Entity</span>
<telerik:RadComboBox ID="businessNameDrop" runat="server" Skin="Web20" Width="150px"
MarkFirstMatch="True" DropDownWidth="150px" CssClass="stateDropDownText" Font-Size="16px"
AutoPostBack="true">
<CollapseAnimation Duration="1000" Type="InOutBack" />
</telerik:RadComboBox>
<asp:SqlDataSource ID="businessDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="getAllBusinesses" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Entity Name</span>
<telerik:RadTextBox ID="entityNameInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Category</span>
<telerik:RadComboBox ID="categoryDrop" runat="server" Skin="Web20" Width="150px"
MarkFirstMatch="True" DropDownWidth="150px" CssClass="stateDropDownText" Font-Size="16px"
DataSourceID="categoriesDataSource" DataTextField="name" DataValueField="categoryid">
<CollapseAnimation Duration="1000" Type="InOutBack" />
</telerik:RadComboBox>
<asp:SqlDataSource ID="categoriesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="getAllAttractionCategories" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td>
<span class="adminTableLabel">Description</span>
<center>
<table>
<tr>
<td>
<telerik:RadTextBox ID="descInput" runat="server" Skin="Web20" Height="150px" Width="150px"
Wrap="true" TextMode="MultiLine">
</telerik:RadTextBox>
</td>
</tr>
</table>
</center>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Street Address</span>
<telerik:RadTextBox ID="streetInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">City</span>
<telerik:RadTextBox ID="cityInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="tableColumn">
<telerik:RadToolTip runat="server" ID="overRideTip" Skin="Web20" Height="60px" Width="250px"
Position="TopRight" RelativeTo="Element" TargetControlID="overRide" AutoCloseDelay="5000"
IsClientID="true">
<span class="normalText">Check this if you would like to enter the latitude and longitude
manually.</span>
</telerik:RadToolTip>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">State</span>
<telerik:RadComboBox ID="stateInput" runat="server" Skin="Web20" Width="150px" ChangeTextOnKeyBoardNavigation="true"
MarkFirstMatch="true" DropDownWidth="150px" CssClass="stateDropDownText" Font-Size="16px">
<CollapseAnimation Duration="1000" Type="InOutBack" />
<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 class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Zip</span>
<telerik:RadTextBox ID="zipInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
<asp:RegularExpressionValidator ID="reZipCode" ControlToValidate="zipInput" ValidationExpression="^((\d{5}){1}|^(\d{5}-\d{4}){1}){1}"
ErrorMessage="Please enter a valid zip code." Display="Dynamic" runat="server"
CssClass="errorMessage" />
<telerik:RadToolTip runat="server" ID="cantFindLocation" Skin="Web20" Height="100px"
Width="400px" ManualClose="true" Position="TopRight" RelativeTo="Element" TargetControlID="streetInput">
<span class="normalText">I can't find the address you specified. Please make sure that
it is typed in correctly. If you would like to manually find the latitude and longitude,
go to <a href="http://itouchmap.com/latlong.html" target="_blank">here</a> and get
the coordinates. <a href="#" onclick="getLatLon()">Look Again</a> </span>
</telerik:RadToolTip>
</center>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Latitude</span>
<telerik:RadTextBox ID="latInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Longitude</span>
<telerik:RadTextBox ID="lonInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="tableColumn">
<a href="#" onclick="getLatLon()" style="font-size: 11px; font-family: Arial;">Find
on map </a>
</td>
</tr>
<tr>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Website</span>
<telerik:RadTextBox ID="siteInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
<td class="addBusinessSpacing">
</td>
<td class="tableColumn">
<center>
<span class="adminTableLabel">Phone Number</span>
<telerik:RadTextBox ID="phoneInput" runat="server" Skin="Web20" Width="150px">
</telerik:RadTextBox>
</center>
</td>
</tr>
</table>
<table>
<tr>
<td>
<table style="margin-left: 140px">
<tr>
<td>
<telerik:RadToolTip ID="toolTip" Skin="Web20"
Position="TopRight" runat="server" Height="100" Width="300"
RelativeTo="Element" HideDelay="25"
TargetControlID="addEntity" VisibleOnPageLoad="false">
</telerik:RadToolTip>
<asp:Button ID="addEntity" runat="server" Text="Change" /><br />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<center>
<asp:Label ID="output" runat="server" Text=""></asp:Label></center>
</td>
</tr>
</table>
</td>
<td class="entityMapClass">
<div id="entityMap">
</div>
</td>
</tr>
</table>
<asp:SqlDataSource ID="usersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
SelectCommand="returnAllNonAdminUsers" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
<asp:Label Style="visibility: hidden;" ID="hiddenJs" runat="server" Text=""></asp:Label>
</telerik:RadAjaxPanel>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" SkinID="Web20"
Height="75px" Transparency="10" BackgroundPosition="Center">
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.LoadingProgressBar.gif") %>'
style="border: 0px;" />
</telerik:RadAjaxLoadingPanel>
</asp:Content>
And here is my vb
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Partial Public Class EditEntity
Inherits System.Web.UI.Page
'my connection string
Dim conn As String = System.Configuration.ConfigurationManager.ConnectionStrings("connectionString").ToString
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'populate the dropdown
Dim tableOfData As DataTable = createTable()
businessNameDrop.DataSource = tableOfData
businessNameDrop.DataTextField = "text"
businessNameDrop.DataValueField = "id"
businessNameDrop.DataBind()
End Sub
'this fires when they change the business name drop down box
Private Sub businessNameDrop_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles businessNameDrop.SelectedIndexChanged
If (businessNameDrop.Text <> "- Please Select -") Then
'the id
Dim entityId As Integer = businessNameDrop.SelectedValue
'set the entity name to the name
entityNameInput.Text = businessNameDrop.SelectedItem.Text
'my sql connection
Dim myConn As New Data.SqlClient.SqlConnection(conn)
'the name of the stored procedure
Dim strSQL = "getEntityInfo"
Dim returnCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)
'add the parameters
returnCommand.Parameters.AddWithValue("@entityId", entityId)
'tell the system it is a stored procedure
returnCommand.CommandType = CommandType.StoredProcedure
Try
myConn.Open()
Dim dr As SqlDataReader = returnCommand.ExecuteReader()
While dr.Read()
'set all of the textboxes to the input
streetInput.Text = dr.Item(0).ToString
cityInput.Text = dr.Item(1).ToString
stateInput.SelectedValue = dr.Item(2).ToString
zipInput.Text = dr.Item(3).ToString
latInput.Text = dr.Item(4).ToString
lonInput.Text = dr.Item(5).ToString
phoneInput.Text = dr.Item(6).ToString
siteInput.Text = dr.Item(7).ToString
descInput.Text = dr.Item(8).ToString
categoryDrop.SelectedValue = dr.Item(9)
End While 'while dr.read()
Catch ex As Exception
output.Text = ("<span class='textRed'>There was an error in retrieving the entity information,<br>" & _
" please contact the system administrator if the problem persists.</span>")
End Try
End If 'if businessNameDrop.text
End Sub
'if they click the add button
Protected Sub addEntity_Click(ByVal sender As Object, ByVal e As EventArgs) Handles AddEntity.Click
'a boolean if the form submission was successful
Dim success As Boolean = True
'all of the user input
Dim entityId As Integer = businessNameDrop.SelectedValue
Dim entityName As String = entityNameInput.Text
Dim street As String = streetInput.Text
Dim city As String = cityInput.Text
Dim state As String = stateInput.SelectedValue
Dim website As String = siteInput.Text
Dim phone As String = phoneInput.Text
Dim zip As Integer = CInt(zipInput.Text)
Dim lat As String = CDbl(latInput.Text)
Dim lon As String = CDbl(lonInput.Text)
Dim fkCatId As Integer = categoryDrop.SelectedValue
Dim desc As String = descInput.Text
'my sql connection
Dim myConn As New Data.SqlClient.SqlConnection(conn)
'the name of the stored procedure
Dim strSQL = "updateEntity"
Dim insertCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)
'add all of the parameters
insertCommand.Parameters.AddWithValue("@entityId", entityId)
insertCommand.Parameters.AddWithValue("@entityName", entityName)
insertCommand.Parameters.AddWithValue("@street", street)
insertCommand.Parameters.AddWithValue("@city", city)
insertCommand.Parameters.AddWithValue("@state", state)
insertCommand.Parameters.AddWithValue("@zip", zip)
insertCommand.Parameters.AddWithValue("@lat", lat)
insertCommand.Parameters.AddWithValue("@lon", lon)
insertCommand.Parameters.AddWithValue("@phone", phone)
insertCommand.Parameters.AddWithValue("@website", website)
insertCommand.Parameters.AddWithValue("@desc", desc)
insertCommand.Parameters.AddWithValue("@fkCatId", fkCatId)
'tell the system its a stored procedure
insertCommand.CommandType = CommandType.StoredProcedure
Try
myConn.Open()
insertCommand.ExecuteNonQuery()
Catch ex As Exception
toolTip.Text = "<span style='color:red;'>There was an error in adding the Place.<br>" & _
"Please contact the system administrator if the problem persists. "
'output.Text = ex.ToString
toolTip.Visible = True
success = False
Finally
myConn.Close()
End Try
If (success) Then
toolTip.Visible = True
toolTip.Text = "<span class='successText'>The entity was successfully updated.</span>"
End If
End Sub
'this sub returns a data table to bind to the dropdown
Private Function createTable()
'a new data table
Dim table As DataTable = New DataTable()
table.Columns.Add("id")
table.Columns.Add("text")
'my sql connection
Dim myConn As New Data.SqlClient.SqlConnection(conn)
'the name of the stored procedure
Dim strSQL = "getAllBusinesses"
'add the initial - Please Select -
table.Rows.Add(New String() {"-1", "- Please Select -"})
Try
myConn.Open()
Dim readCommand As New Data.SqlClient.SqlCommand(strSQL, myConn)
'while we have rows from the stored procedure
'we will add them to a data table
Dim cdr As SqlDataReader = readCommand.ExecuteReader()
While cdr.Read()
If (cdr.Item(0).ToString <> "") Then
table.Rows.Add(New String() {cdr.Item(0), cdr.Item(1)})
End If
End While 'while cdr.Read()
Catch ex As Exception
output.Text = "There was an internal error. Please reload the page.<br>" & _
"If the problem persists, contact the system administrator"
End Try
myConn.Close()
Return table
End Function 'createTable
End Class
Thanks,