Seems like an easy thing, but no quite so apparently.
I have a look up page that does a complicated search of a database (first name, last_name ...) that is used as a common look up across an application. It run through a colorbox popup and then callsback to a generic js function on the calling page to set the result on the calling page as well as close the popup.
The problem is this requires alot of setup on the calling page, including writing the callback function that sets the values. (I can't modify the lookup page, have to work with it as is)
I've pulled the layout into a user control and now want to push the callback function to the page ONLY if another copy of the function doesn't already exist. This is the question. In my ascx code behind, how can I look to see if the page already contains the js function I"m looking for so that I don't duplicate that function?
Hopefully that's clear as mud. I've been googling this for a while and haven't found anything other than how to use js to determine if a js function exist (not what I need). Any help would be appreciated.
Use the RegisterClientScriptBlock
method to add the script to the page:
Page.ClientScript.RegisterClientScriptBock(Page.GetType(), "callback", theScript, true);
The script will only be added to the page as long as there isn't one already added with the same type and name.