HOW TO

Set initial extent for .NET Web application

Last Published: April 25, 2020

Summary

At design time, the InitialExtent property of a map control can be set to default or full.

Default uses the extent of the primary map resource. Full uses an extent that includes all resources in the map. To explicitly set the extent of the map control upon application initialization, add the appropriate code to the PreRender event of the page or map. The following procedure uses a custom Web ADF envelope to define the initial extent of the map.

Note:
The initial extent only needs to be set on the initial request to the application, not on every subsequent postback.

Procedure

1. Go to C:\Inetpub\wwwroot\<your Web site> folder. Open Default.aspx.cs file in Notepad.

2. Copy the following code into any two 'protected void' sessions and change the extent to the desired extent values:
Code:
protected void Page_PreRender(object sender, EventArgs ea){
if (!Page.IsPostBack){
ESRI.ArcGIS.ADF.Web.Geometry.Envelope initextent = new

ESRI.ArcGIS.ADF.Web.Geometry.Envelope(-110, 30,-100, 40);
Map1.Extent = initextent;
}
}


3. Save the file and refresh the Web site.

    Article ID: 000009606

    Software:
    • ArcGIS Server

    Receive notifications and find solutions for new or common issues

    Get summarized answers and video solutions from our new AI chatbot.

    Download the Esri Support App

    Discover more on this topic

    Get help from ArcGIS experts

    Contact technical support

    Download the Esri Support App

    Go to download options