Tuesday, August 23, 2005

Hidden Input Element

HTML Hidden input element is typically used to transfer hidden data between the client and server. When writing a JSP or ASP application, you might have added a few hidden inputs to your page to persist the data between page reloads. With the evolution of server side technologies like .NET and JSF, the state of a control in the webpage is typically managed in the server side. It is, however, not efficient and sometimes almost impossible to put all data on the server and go back and forth between client and server for every user interaction. Say, for example, in a GIS web application, it would be impossible to post a request to the server to get the map coordinate every time you move the mouse on the map. Hence an efficient web application requires an optimum usage of client side and server side logic which in turn requires transferring the data back and forth between the server and client to make the two sides in synch with each other. The hidden input element can be handy in transferring such data. A typical example of using hidden input elements in a GIS application is passing the updated map extent (minx, miny, maxx, maxy values) between the server and the client.

In my previous blog, I made use of a hidden input element to persist the web page state maintained in the client side. I helped a user with a similar problem using the hidden input element a while ago. This was in .NET. So I thought it would be nice to take a break from Java and talk about it.

The problem was to enable/disable a tool item in the toolbar of the ArcGIS Server MapViewer template on the client side through Javascript without posting back the form immediately. The toolbar is managed by the .NET ADF on the server side. So if you simply change the property on the client side and do not somehow update the change on the server side, you will lose your change the next time your website is loaded. You can, of course, post back the form everytime you enable/disable a toolitem in the client side to synch the server with the client state. However, this means you need to post the form each time you make this change which is not an ideal solution. What would be an ideal solution is to use javascript to enable/disable the toolbar item and when the next time the form is posted, update the state of the toolbar to synch it with the client state.

As mentioned before, we can make use of hidden input control run at the server side to do this. Lets discuss how we can customize the .NET MapViewer template to achieve this functionality:

1. Add a hidden HTML input element to the Default page of the MapViewer template application. Set it to "Run as server Control". Make sure that this is added within the Form element in the HTML source.

2. Add an HTML Button to the page. We will use this button to test our function. Specify onclick="disableToolItem('ZoomOut');" for this button. This button when clicked calls disableToolItem function on the client side and does not post the form.

3. Now lets take a look at disableToolItem function:

function disableToolItem(toolItem){
var f = document.forms[0];
var listValues="";
var Toolbar1 = Toolbars['Toolbar1'];
var items1 = Toolbar1.Items;
disableTool(toolItem, !items1[toolItem].Disabled, true);

listValues += (items1['ZoomIn'].Disabled) ? "0":"1";
listValues += (items1['ZoomOut'].Disabled) ? ":0":":1";
listValues += (items1['Pan'].Disabled) ? ":0":":1";
listValues += (items1['FullExtent'].Disabled) ? ":0":":1";
listValues += (items1['ZoomBack'].Disabled) ? ":0":":1";
listValues += (items1['ZoomNext'].Disabled) ? ":0":":1";
listValues += (items1['Identify'].Disabled) ? ":0":":1";
f.elements['activeToolList'].value = listValues;

Notice that it first toggles the disable property of the given toolItem by calling the custom
function disableTool (see below) and generates a String in
this format: 0:1:1:1:0 where 0 and 1 represent the disabled
and enabled state of the toolitem respectively. It then assigns this value
to the hidden input element and refreshes the toolbar.

4. The disableTool function is given below:

function disableTool(itemName, disable, isTool ){
var Toolbar1 = Toolbars['Toolbar1'];
var items1 = Toolbar1.Items;
items1[itemName].Disabled = disable;
var cellName = 'Toolbar1' + itemName;
var thisCellElement =
thisCellElement.onmousedown == null;
thisCellElement.onmouseover == null;
thisCellElement.onmouseout == null;
} else {
thisCellElement.onmousedown = function () {
if (isTool)
ToolbarMouseDown('Toolbar1', itemName, 'Tool');
ToolbarMouseDown('Toolbar1', itemName, 'Command');

thisCellElement.onmouseover = function () {
ToolbarMouseOver('Toolbar1', itemName);

thisCellElement.onmouseout = function () {
ToolbarMouseOut('Toolbar1', itemName);


This function gets the specified toolbar item and nullifies the
mouse events if disabling. It will activate the mouse events
for toolbar item if enabling.

5. Add the above functions to toolbar_functions.js file in C:\Inetpub\wwwroot\aspnet_client\esri_arcgis_server_webcontrols\9_1\JavaScript folder. (Be sure to keep a back up copy of the original file before you make any change to it.)

6. We need to modify the existing functions as follows:
a) Find ToolbarMouseDown function in toolbar_functions.js file . Inside this function find
this line:

var toolbar = Toolbars[toolbarName];

Add this line after the above line:

if(toolbar.Items[toolbarItemName].Disabled) return;

b) Inside ToolbarMouseOver function, find this line:

var toolbar = Toolbars[toolbarName];

Add this line after the above line:

if(toolbar.Items[toolbarItemName].Disabled) return;

c) Inside ToolbarMouseOut function, find this line:

var toolbar = Toolbars[toolbarName];

Add this line after the above line:

if(toolbar.Items[toolbarItemName].Disabled) return;

7. Finally, we need to update the server state when the page is posted back. Modify the Page_Load method of Default page as shown below:

private void Page_Load(object sender, System.EventArgs e)
// Check parameters of MapControl
// If there is no Host or ServerObject defined,
// then there is no point to continuing since there will be no map to display
if ( (Map1.Host == null) (Map1.Host == String.Empty) )
callErrorPage("Host property not defined for the Map control.", null);
if ( (Map1.ServerObject == null)
(Map1.ServerObject == String.Empty)
(Map1.ServerObject == "(none)") )
callErrorPage("ServerObject property not defined for the Map control.", null);
if (!Map1.AutoFirstDraw)
callErrorPage("The property AutoFirstDraw of
the Map WebControl must be set to true
for this application to run.", null);
// check if the server object can be accessed
ESRI.ArcGIS.Server.WebControls.ServerConnection connection =
if ( connection == null )
callErrorPage("Invalid ServerConnection.", null);

// check if the server object is pooled
isPooled = connection.IsServerObjectPooled(Map1.ServerObject,"MapServer");

string activeTools="";
// Is this a PostBack or just started
if ( !Page.IsPostBack )
// Is this a new session?
if ( Session.IsNewSession )
// Save extent history to Session
m_extenthistory = new ArrayList();
Session.Add("extenthistory", m_extenthistory);
m_lastextent = Map1.Extent;

//if new session, generate the string to store
//the enable/disable status of toomitems
//the value will be stored in 1:0:0:1:1 format
//where 1=enable, 0=disable

int toolLength = Toolbar1.ToolbarItems.Count;
for (int i=0;i<toolLength;i++)
string disableOrNot = "1";
Tool tool = Toolbar1.ToolbarItems[i] as Tool;
if(tool.Disabled) disableOrNot = "0";
if(i==0) activeTools = disableOrNot;
else activeTools = activeTools + ":" + disableOrNot;
} else {
Command command1 = Toolbar1.ToolbarItems[i] as Command;
if(command1.Disabled) disableOrNot = "0";
if(i==0) activeTools = disableOrNot;
else activeTools = activeTools + ":" + disableOrNot;
//set the value to the hidden input control
activeToolList.Value = activeTools;
} else {
//if not a new session
//get the values from the input control
//and update the toolitem property

activeTools = activeToolList.Value;
if((activeTools != "") && (activeTools != null))
char[] sep = {':'};
Array aa = activeTools.Split(sep);
for(int i = 0;i<aa.Length;i++)
Tool tool = Toolbar1.ToolbarItems[i] as Tool;
if(tool != null)
if (aa.GetValue(i).ToString()=="0") tool.Disabled = true;
else tool.Disabled=false;
} else {
Command command1 = Toolbar1.ToolbarItems[i] as Command;
if (aa.GetValue(i).ToString()=="0") command1.Disabled = true;
else command1.Disabled=false;
// make sure that the session is still going, if not, display error page
if (Session["extenthistory"]==null)
callErrorPage("Your session has timed out.", null);

sessionId = Session.SessionID;
string scriptString = "\n<script language=javascript>sessionId = '"
+ sessionId + "'; </script>\n";
Page.RegisterStartupScript("SessionIdScript", scriptString);
// get name of session object holding map description
string pagePath = Page.Request.FilePath;
string pageName = "";
int lastSlash = pagePath.LastIndexOf("/");
if (lastSlash>-1) pageName = pagePath.Substring(lastSlash+1);
m_MapDescriptSessName = pageName + Map1.ID + "_md";

Notice above that when the new session is started, we get the toolitem property and
generate the string to assign it to hidden input control. If this is not a new session but a postback request, we parse the value of hidden input control and update the property of the toolitem appropriately. This makes the state of the server toolbar in synch with that on the client side.


At 5:39 AM, Anonymous Anonymous said...

Just visited your blog, it's great. I have a domain free hosting name registration web
website which is informative and you can find info of different domain free hosting name registration web
, hope that it will be useful.

At 8:58 PM, Blogger Antonio Hicks said...

I was just browsing various blogs as I was doing a search on the word poster, and I just wanted to say that I really like what you've done with your blog, even though it wasn't particularly related to what I searched for. I appreciate your postings, and your blog is a good example of how a blog should be done. I've only just recently started a Posters website - feel free to visit it when you get a chance if you wish. Much success, antonio.

At 2:22 AM, Anonymous Anonymous said...

Cingular Ringtones
Pay Day Loan
Stop Smoking
Quit Smoking
Mosquito Ringtone
Free Nokia Ringtone
Nokia Ringtones
Polyphonic Ringtones
Nokia Ringtones
Free Ringtones
Pay Day Loan
Car Loan

At 9:48 AM, Anonymous Anonymous said...

Learn how to install your Webserver Software & How to install PHP, MYSQL,PERL,PHPMYADMIN + MORE 100% FREE


How to host unlimited websites & domains for free.
How to install Webserver Software on your PC easily.
How to install PHP , MYSQL , PHPMYADMIN, PERL & ZEND... on your PC
Replicator site + MYSERVER Tutorials software to earn lots of money paid instantly to your PAYPAL account + how to promote it to millions 100% FREE.
And Much More...

Go here now : http://lnk.in/4cur



Thank you and hurry.

At 4:40 PM, Anonymous Anonymous said...


How do you change the size of your monitor?

By the way, I love that too!  Where did you get that at?  

See you soon! Girly Girl 

how I make money with paid surveys

At 3:44 AM, Anonymous Anonymous said...

Hello all Nice site kafle.blogspot.com! Thanks.
http://www11.asphost4free.com/tramadolrx/Tramadol.html tramadol tramadol

At 6:11 AM, Anonymous Anonymous said...

Hello! Good forum www.blogger.com! Thank you!
cheap tramadol incest stories ivana fukalot

At 12:52 PM, Anonymous Anonymous said...

Hi all!
nice design, great info

phentermine diet pills pharmacy rape videos Generic levitra buy cheap drugs cartoon incest

At 10:10 PM, Anonymous Anonymous said...

Hi there 

Wow, I've found the same to be true too!  Where did you get that at?  

See you soon! Girly Girl 

[url=online-paid-survey-yahoocomazzramlu.blogspot.com]see how I make free money with paid online surveys[/url]

At 3:30 AM, Anonymous Anonymous said...

Best site in web www.blogger.com!
Buy cheap adipex online! Buy cheap tramadol online! brother sister sex cartoon incest Buy cheapest cialis pharmacy daughter incest .
[url=http://www.volny.cz/ph24/cheap-adipex.html]cheap adipex[/url] [url=http://www.volny.cz/ph24/cheap-tramadol.html]cheap tramadol[/url] [url=http://www.volny.cz/ph24/porn/brother-sister-sex.html]brother sister sex[/url] [url=http://www.volny.cz/ph24/porn/cartoon-incest.html]cartoon incest[/url] [url=http://www.volny.cz/ph24/porn/daughter-incest.html]daughter incest[/url] [url=http://www.volny.cz/ph24/cheapest-cialis.html]cheapest cialis[/url]
http://www.volny.cz/ph24/cheap-adipex.html http://www.volny.cz/ph24/cheapest-cialis.html http://www.volny.cz/ph24/cheap-tramadol.html http://www.volny.cz/ph24/porn/brother-sister-sex.html http://www.volny.cz/ph24/porn/cartoon-incest.html http://www.volny.cz/ph24/porn/daughter-incest.html

At 10:00 PM, Anonymous Anonymous said...

nice design on www.blogger.com, great info
http://www.volny.cz/ph24/cialis-drug.html cialis drug [url=http://www.volny.cz/ph24/cialis-drug.html]cialis drug[/url]
http://www.volny.cz/ph24/generic-levitra.html generic levitra [url=http://www.volny.cz/ph24/generic-levitra.html]generic levitra[/url]
http://www.volny.cz/ph24/porn/forced-sex.html forced sex [url=http://www.volny.cz/ph24/porn/forced-sex.html]forced sex[/url]
http://www.volny.cz/ph24/porn/family-incest.html family incest [url=http://www.volny.cz/ph24/porn/family-incest.html]family incest[/url]
http://www.volny.cz/ph24/phentermine-37.5-mg.html phentermine 37.5 mg [url=http://www.volny.cz/ph24/phentermine-37.5-mg.html]phentermine 37.5 mg[/url]
http://www.volny.cz/ph24/porn/hardcore-fucking.html hardcore fucking [url=http://www.volny.cz/ph24/porn/hardcore-fucking.html]hardcore fucking[/url]

At 7:35 PM, Anonymous Anonymous said...

Hello all
Best site in web www.blogger.com!
http://www.enunblog.com/adipexnoprescription/ adipex no prescription adipex adipex without a prescription [url=http://www.enunblog.com/adipexnoprescription/]adipex no prescription[/url] buy adipex [url=http://www.enunblog.com/adipexnoprescription/]adipex without a prescription[/url]
http://www.enunblog.com/cheapphentermine/ cheap phentermine phentermine buy phentermine [url=http://www.enunblog.com/cheapphentermine/]cheap phentermine[/url] cheap phentermine [url=http://www.enunblog.com/cheapphentermine/]buy phentermine[/url]
http://www.enunblog.com/rapevideos/ rape videos rape forced sex [url=http://www.enunblog.com/rapevideos/]rape videos[/url] rape video [url=http://www.enunblog.com/rapevideos/]rape porn[/url]
http://www.enunblog.com/beastiality/ beastiality beastiality horse sex [url=http://www.enunblog.com/beastiality/]beastiality[/url] [url=http://www.enunblog.com/beastiality/]horse sex[/url]
http://www.enunblog.com/buytramadol/ buy tramadol tramadol tramadol hcl [url=http://www.enunblog.com/buytramadol/]buy tramadol[/url] cheap tramadol [url=http://www.enunblog.com/buytramadol/]tramadol hcl[/url]
http://www.enunblog.com/incestporn/ incest porn incest family incest [url=http://www.enunblog.com/incestporn/]incest porn[/url] family incest [url=http://www.enunblog.com/incestporn/]incest stories[/url]

At 8:06 AM, Anonymous Anonymous said...

Best site in web www.blogger.com!
Phentermine diet pills
phentermine 37.5 mg incest beastiality [url=http://phenterminedp.jconserv.net/]phentermine 37.5 mg[/url] [url=http://incestxxx.jconserv.net]incest[/url] [url=http://anne.messageboard.nl/24273/]beastiality[/url] http://phenterminedp.jconserv.net/ http://incestxxx.jconserv.net http://anne.messageboard.nl/24273/

At 8:33 AM, Anonymous Anonymous said...

Hello all
Good design on www.blogger.com, great info.
Best online drugstore. Buy adipex meridia propecia hydrocodone:
http://daniell.hostuju.cz/coumadin.html coumadin [url=http://daniell.hostuju.cz/coumadin.html]coumadin[/url]
http://daniell.hostuju.cz/buy-hydrocodone.html buy hydrocodone [url=http://daniell.hostuju.cz/buy-hydrocodone.html]buy hydrocodone[/url]
http://209384.hostuju.cz/ivana-fukalot.html ivana fukalot [url=http://209384.hostuju.cz/ivana-fukalot.html]ivana fukalot[/url]
http://209384.hostuju.cz/cumshots.html cumshots [url=http://209384.hostuju.cz/cumshots.html]cumshots[/url]
http://daniell.hostuju.cz/buy-propecia.html buy propecia [url=http://daniell.hostuju.cz/buy-propecia.html]buy propecia[/url]
http://209384.hostuju.cz/mother-son-sex.html mother son sex [url=http://209384.hostuju.cz/mother-son-sex.html]mother son sex[/url]

At 6:33 PM, Anonymous Anonymous said...

[URL=http://alba-jessica-topless.cndsk.info/]alba jessica topless[/URL]


At 2:38 AM, Anonymous Anonymous said...

Nice site in web www.blogger.com!
Cheap drugstore online. Buy coumadin meridia propecia:
http://daniell.hostuju.cz/adipex.html adipex [url=http://daniell.hostuju.cz/adipex.html]adipex[/url] http://daniell.hostuju.cz/buy-hydrocodone.html buy hydrocodone [url=http://daniell.hostuju.cz/buy-hydrocodone.html]buy hydrocodone[/url] http://209384.hostuju.cz/cartoon-incest.html cartoon incest [url=http://209384.hostuju.cz/cartoon-incest.html]cartoon incest[/url] http://209384.hostuju.cz/hardcore-fucking.html hardcore fucking [url=http://209384.hostuju.cz/hardcore-fucking.html]hardcore fucking[/url] http://users.nethit.pl/cgi-bin/vote/vote?tramadolhcl tramadol hcl [url=http://users.nethit.pl/cgi-bin/vote/vote?tramadolhcl]tramadol hcl[/url] http://ivanafukalot.forumup.us/ ivana fukalot [url=http://ivanafukalot.forumup.us/]ivana fukalot[/url]

At 2:22 AM, Anonymous Anonymous said...

Nice site in web www.blogger.com!
Good Drugstore Online. Buy tramadol cialis adipex:
http://44490-0.forum.alluwant.de buy adipex online [url=http://44490-0.forum.alluwant.de]buy adipex online[/url] http://cheapescialis.blogcu.com/ cheapest cialis [url=http://cheapescialis.blogcu.com/]cheapest cialis[/url] http://forced-blowjob-sex.da.cx/ forced blowjob sex [url=http://forced-blowjob-sex.da.cx/]forced blowjob sex[/url] http://freeforen.com/phpbb/phpbb2367 beastiality [url=http://freeforen.com/phpbb/phpbb2367]beastiality[/url]

At 9:24 PM, Anonymous Anonymous said...

Good design on www.blogger.com, good info.
Buy cheap tramadol online:
http://ustramadol.monforum.fr/index.php tramadol [url=http://ustramadol.monforum.fr/index.php]tramadol[/url]

At 8:06 AM, Anonymous Anonymous said...

Hello all
Good site www.blogger.com, thank you!
Buy cheap adipex no prescription
http://www.iwannaforum.com/adipexnop adipex no prescription [url=http://www.iwannaforum.com/adipexnop]adipex no prescription[/url] http://anne.messageboard.nl/24841 incest porn [url=http://anne.messageboard.nl/24841]incest porn[/url] http://incest-mature-stories.com/2007/03/09/a-mothers-new-love-for-her-son/ http://www.iwannaforum.com/rvideos/ [url=http://www.iwannaforum.com/rvideos/]rape videos[/url]

At 5:51 AM, Anonymous Anonymous said...

Hello all
Nice site in web www.blogger.com.
Buy generic levitra online
Buy hydrocodone http://site.voila.fr/usmeds/buy_hydrocodone.html buy hydrocodone [url=http://site.voila.fr/usmeds/buy_hydrocodone.html]buy hydrocodone[/url] http://interracial-porn.ar.vg/ interracial porn [url=http://interracial-porn.ar.vg/]interracial porn[/url] coumadin http://site.voila.fr/usmeds/coumadin.html coumadin [url=http://site.voila.fr/usmeds/coumadin.html]coumadin[/url] http://anal-fucking.ve.tc/ anal fucking [url=http://anal-fucking.ve.tc/]anal fucking[/url] hydrocodone http://site.voila.fr/usmeds/hydrocodone.html hydrocodone [url=http://site.voila.fr/usmeds/hydrocodone.html]hydrocodone[/url] http://site.voila.fr/usmeds/generic_levitra.html generic levitra [url=http://site.voila.fr/usmeds/generic_levitra.html]generic levitra[/url]

At 9:16 PM, Anonymous Anonymous said...

Nice site in web www.blogger.com.
Buy generic levitra online
Buy adipex http://site.voila.fr/usmeds/buy_adipex.html buy adipex [url=http://site.voila.fr/usmeds/buy_adipex.html]buy adipex[/url] http://forced-sex.mx.vg/ forced sex [url=http://forced-sex.mx.vg/]forced sex[/url] Buy maridia http://site.voila.fr/usmeds/buy_meridia.html buy meridia [url=http://site.voila.fr/usmeds/buy_meridia.html]buy meridia[/url] http://anal-fucking.ve.tc/ anal fucking [url=http://anal-fucking.ve.tc/]anal fucking[/url] Generic levitra http://site.voila.fr/usmeds/generic_levitra.html generic levitra [url=http://site.voila.fr/usmeds/generic_levitra.html]generic levitra[/url] http://incest-stories.pa.kz/ incest stories [url=http://incest-stories.pa.kz/]incest stories[/url] http://spod.cx/s?1553 beastiality [url=http://spod.cx/s?1553]beastiality[/url]

At 3:04 AM, Anonymous OnlinePharmacy said...

cSmxE8 Your blog is great. Articles is interesting!

At 11:09 AM, Anonymous buy dosage orxc com from link phentermine html via said...

qRPY0o Nice Article.

At 12:22 PM, Anonymous generic available for meridia said...


At 12:48 PM, Anonymous cheaper in motel panama repub said...

Hello all!

At 12:23 PM, Anonymous name said...

Thanks to author.

At 1:12 PM, Anonymous chicago architecture walking tour said...

Nice Article.

At 7:57 AM, Anonymous de france team tour said...

Thanks to author.

At 11:25 PM, Anonymous samaritan insurance said...

Wonderful blog.

At 2:39 AM, Anonymous ringtones said...

Thanks to author.

At 6:30 AM, Anonymous  said...

Thanks to author.

At 11:43 AM, Anonymous inlevitra rserver said...

klKQkf Thanks to author.

At 12:11 PM, Anonymous moto q and free ringtones said...

Hello all!

At 2:33 PM, Anonymous US children furniture said...

Just visited your blog, it's great. I have a domain free hosting name registration webwebsite which is informative and you can find info of different domain free hosting name registration web, hope that it will be useful.

At 2:27 AM, Blogger hibeyond said...

black boots

Chocolate boots

sand boots

Chestnut boots

gray boots

pink boots

grey boots

pink boots

At 3:46 PM, Anonymous vrnjacka banja said...

This is a wonderful content. I will bookmark this site and visit again. It is very informative. Thanks for sharing.
vrnjacka banja smestaj
vrnjacka banja privatni smestaj

At 5:12 AM, Anonymous pepa prase said...

I'm so excited. I really appreciate sharing this great post. Keep up your excellent work.
bojanke za decu
gledanje u solju

At 5:57 AM, Anonymous banja srbija said...

Excellent post. I want to thank you for this informative read. I will bookmark this site and visit again..
Banje u Srbiji
Banje Srbije


Post a Comment

<< Home