initialize a variable on first instance of a custom control

lamy

Regular
Joined
Dec 12, 2005
Messages
56
Location
under your bed
lets say i have several instances of the same custom control and i wanted the first one to load something and ignore that procedure with the rest of the custom control since its already loaded, anyone for directions?

was thinking of putting this in my custom control

Code:
<script language="javascript" src="something"></script>

but i wanted it to load only once even if i keep dragging more of the same custom control, anyone?

i can do a workaround like saving something in a session/viewstate, then check it from there, but there could be another way
 
found an article for the solution, it was to emit it once for all server controls, however i keep on getting this "obsolete" warning at "Page.RegisterClientScriptBlock" line, im using VS 2005 Express

Visual Basic:
 Const displayScriptKey As String = "someScript" 
 If Not Page.IsClientScriptBlockRegistered(displayScriptKey) Then 
   Page.RegisterClientScriptBlock(displayScriptKey, script) 
 End If
 
*** resolved

Visual Basic:
Const displayScriptKey As String = "someScript" 
 If Not Page.ClientScript.IsClientScriptBlockRegistered(displayScriptKey) Then 
   Page.ClientScript.RegisterClientScriptBlock(Me.GetType, displayScriptKey, script) 
 End If
 
Back
Top