Gets or sets a value that indicates whether a server control is rendered as UI on the page. (Inherited from Control.)
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As Map
Dim value As Boolean
instance.Visible = value
value = instance.Visible |
Property Value
Boolean value indicating current visibility setting of Map control.
Example
The examples below toggle the visibility of the Map. The first example uses client-side JavaScript. This is the preferred approach unless your application is doing a callback for another purpose, and you need to set the visibility during the callback. In that case, use an approach similar to the second example.
The ASPX pages are set to C#--if using VB, change these references to VB in order to use this example. You may also need to change version number for ESRI Web controls. See the Remarks section for a discussion of setting visibility of the map.
EXAMPLE 1: toggles the visibility of the map in client by a JavaScript function that changes the display style of the map. Use this approach unless you are performing a callback for another purpose and need to set the visibility during that callback.
C# | Copy Code |
---|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Map-ToggleVisibility.aspx.cs" Inherits="Map_ToggleVisibility" %>
<%@ Register Assembly="ESRI.ArcGIS.ADF.Web.UI.WebControls, Version=9.3.0.1635, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86"
Namespace="ESRI.ArcGIS.ADF.Web.UI.WebControls" TagPrefix="esri" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function ToggleMapClient()
{
var map = document.getElementById("Map1");
if (map != null) {
if (map.style.display == "none")
map.style.display = "block";
else
map.style.display = "none";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
This button toggles map visibility on the client:
<input id="btnToggleMapOnClient" type="button" value="Toggle Map (Client)"
onclick="ToggleMapClient()" /><br />
<esri:Map ID="Map1" runat="server" Height="279px" MapResourceManager="MapResourceManager1"
Style="" Width="383px">
</esri:Map>
<esri:MapResourceManager ID="MapResourceManager1" runat="server" ><ResourceItems>
<esri:MapResourceItem Name="MapResourceItem0"
DisplaySettings="visible=True:transparency=0:mime=True:imgFormat=PNG8:height=100:width=100:dpi=120:color=:transbg=False:displayInToc=True"
Definition="<Definition DataSourceDefinition="localhost@5300" DataSourceType="ArcIMS" Identity="" ResourceDefinition="World" DataSourceShared="True" />">
</esri:MapResourceItem>
</ResourceItems>
</esri:MapResourceManager>
</div>
</form>
</body>
</html> |
EXAMPLE 2: toggles the visibility of the map during a callback. Use this approach only if your application is doing a callback for another purpose and you need to set the map visibility during the callback. Code-behind for C# and VB follow the ASX page.
C# | Copy Code |
---|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Map-ToggleVisibility.aspx.cs" Inherits="Map_ToggleVisibility" %>
<%@ Register Assembly="ESRI.ArcGIS.ADF.Web.UI.WebControls, Version=9.3.0.1635, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86"
Namespace="ESRI.ArcGIS.ADF.Web.UI.WebControls" TagPrefix="esri" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function ToggleMapCallback()
{
var message = 'toggleMap';
var context = 'Map1';
<%=sCallBackFunctionInvocation %>
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
This button toggles map visibility using a callback:
<input id="btnToggleMapCallback" type="button" value="Toggle Map (Callback)"
onclick="ToggleMapCallback()" />
<esri:Map ID="Map1" runat="server" Height="279px" MapResourceManager="MapResourceManager1"
Style="" Width="383px">
</esri:Map>
<esri:MapResourceManager ID="MapResourceManager1" runat="server" ><ResourceItems>
<esri:MapResourceItem Name="MapResourceItem0"
DisplaySettings="visible=True:transparency=0:mime=True:imgFormat=PNG8:height=100:width=100:dpi=120:color=:transbg=False:displayInToc=True"
Definition="<Definition DataSourceDefinition="localhost@5300" DataSourceType="ArcIMS" Identity="" ResourceDefinition="World" DataSourceShared="True" />">
</esri:MapResourceItem>
</ResourceItems>
</esri:MapResourceManager>
</div>
</form>
</body>
</html> |
This is the C# code-behind for the callback-based visibility sample above.
C# | Copy Code |
---|
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class Map_ToggleVisibility : System.Web.UI.Page, ICallbackEventHandler
{
protected string sCallBackFunctionInvocation;
protected void Page_Load(object sender, EventArgs e)
{
sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "processCallbackResult", "context", "postBackError", true);
}
#region ICallbackEventHandler Members
private string callbackArg;
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
callbackArg = eventArgument;
}
string ICallbackEventHandler.GetCallbackResult()
{
string returnString = "";
if (callbackArg.Contains("toggleMap"))
{
// change the Style property via a callback
string getMap = String.Format("var map = document.getElementById('{0}');", Map1.ClientID);
string mapVis = "map.style.display = (map.style.display=='none')? 'block':'none';";
string jsFunctionVisibility = String.Concat(getMap, mapVis);
ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult cbrSetVisibility =
new ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(
null, null, "javascript", jsFunctionVisibility);
returnString = cbrSetVisibility.ToString();
}
return returnString;
}
#endregion
} |
This is the VB code-behind for the callback-based visibility sample above.
Visual Basic | Copy Code |
---|
Partial Class Map_ToggleVisibilityVB
Inherits System.Web.UI.Page
Implements ICallbackEventHandler
Protected sCallBackFunctionInvocation As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(Me, "message", "processCallbackResult", "context", "postBackError", True)
End Sub
' ICallbackEventHandler Members
Private callbackArg As String
Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
callbackArg = eventArgument
End Sub
Public Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
Dim ReturnString As String = ""
If callbackArg.Contains("toggleMap") Then
' change the Style property via a callback
Dim getMap As String = String.Format("var map = document.getElementById('{0}');", Map1.ClientID)
Dim mapVis As String = "map.style.display = (map.style.display=='none')? 'block':'none';"
Dim jsFunctionVisibility As String = String.Concat(getMap, mapVis)
Dim cbrSetVisibility As New ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult( _
Nothing, Nothing, "javascript", jsFunctionVisibility)
ReturnString = cbrSetVisibility.ToString()
End If
Return ReturnString
End Function
End Class |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also