Wednesday, December 26, 2012

Client Scripts basics

It took me a while to get to these but once I started to realize their use, I began to use them constantly.  You can find client scripts in the XFD Designer under a tab with the same name.  After a quick perusal you'll realize, like I did, that these contain common repeatable tasks.  Tasks you should code once and then just call over and over. 

Seeing how I am always looking for good ways to be efficient, I took the bait and started playing with them.  First was figuring out how to use them.

Let's start there.

Go to the form properties view, under MISC in the Scripts collection.  Click to open up a reference form that allows you to choose one or more scripts to add.  You'll get a view into the same scripts you just saw under the Client Scripts tab.  Take a look around and find one you want to add.

This may seem dumb to note but make sure you hit the "add" button on the top right hand of the RefPickerForm to actually add your script.  Double clicking to the view script doesn't actually add it, though it does let you look at what's in the script.  Once done (you can add more than one), hit okay.  Review the scripts you have added and then save.  Did I mention you want to save?

Anyway, once you have the client script referenced you can use it's code like you had it in the code behind.  Very useful when your goal is to maintain code reuse.  Its worth your time to define some of your more common actions and then just reference them.  The Utilities category of the Applications in the XFD Designer is full of good scripts and the Client Scripts tab gives you a full view of existing client scripts.

No comments:

Post a Comment