Heya Trev, Normally these types of JS references would be included in a masterpage, or something else which is shared across the components - but in your case, it looks like you don't have that luxuary. Perhaps you could have your code look to its parent, and check whether any other fields of the same type exist on the page yet, and if they do, don't output the script. You can't use a static variable here because it does not persist cross-postback. You could though, however, store a flag into session state, and check whether it's set - if it is, don't render the script - otherwise, render it and set the flag. You could also perist it into viewstate.
M On Fri, Apr 24, 2009 at 2:13 PM, Trevor Andrew <[email protected]>wrote: > Hi All, > > > > We have a custom field type in which we do some custom rendering, and also > include references via <script> tags to some external JavaScript libraries, > functions from which we call. On a list where we have two instances of this > custom field type, the references to include the JavaScript libraries are > included twice. It doesn’t appear to adversely impact the operation of the > fields, but is inefficient I assume, and I’d like to eliminate it. > > > > I’ve tried creating an Integer Static in the custom field type class, in an > endeavour to only include the references to the JavaScript libraries on the > rendering of the “first” instance of the field on the page. But the number > just continues to mount across page re-renderings, making it difficult to > determine the minimum . Any thoughts or suggestions? > > > > Cheers, > > Trevor Andrew > > > ------------------------------ > Support procedure: https://www.codify.com/lists/support > List address: [email protected] > Subscribe: [email protected] > Unsubscribe: [email protected] > List FAQ: http://www.codify.com/lists/ozmoss > Other lists you might want to join: http://www.codify.com/lists > -------------------------------------------------------------------------------- Support procedure: http://www.codify.com/lists/support List address: [email protected] Subscribe: [email protected] Unsubscribe: [email protected] List FAQ: http://www.codify.com/lists/ozmoss Other lists you might want to join: http://www.codify.com/lists
