Is there a possibility to have the
Sys.UI.DomEvent.addHandler($get('ButtonID'),'click',myfunc) in a file as
well?
Regards
RADIUM
"Axel Gallus" <(E-Mail Removed)> schrieb im Newsbeitrag
news:fnhtte$u19$(E-Mail Removed)...
> Thx - where exactly do I register the js-file which contains my "myfunc" ?
>
> Regards
>
> R4DIUM
>
>
> "Milosz Skalecki [MCAD]" <(E-Mail Removed)> schrieb im
> Newsbeitrag news
4F348B4-8204-4C6D-8964-(E-Mail Removed)...
>> Howdy,
>>
>> Leave the function declaration as it is, and paste this to Page_Load, or
>> Page_PreRender event handler:
>>
>> string script = String.Format(
>> "Sys.UI.DomEvent.addHandler($get('{0}'),'click',myfunc);",
>> btn.ClientID);
>>
>> ClientScript.RegisterStartupScript(this.GetType(), "whatever",
>> script, true);
>>
>> Regards
>> --
>> Milosz
>>
>>
>> "news.rz.uni-karlsruhe.de" wrote:
>>
>>> I wrote an event handler with
>>> Sys.UI.DomEvent.addHandler($get("MyButton"),"click",myfunc);
>>>
>>> function myfunc(event)
>>>
>>> {
>>>
>>> alert("Hi!");
>>>
>>> }
>>>
>>> 1.) If I write this code as a javascript block after the page under the
>>> closing </html> tag everything works fine.
>>>
>>> 2.) If I write this code as a javascript block between the <head> tags I
>>> get
>>> an null pointer error from $get("MyButton").
>>>
>>> 3.) I get the same error if I use the
>>> ScriptManager.Scripts.Add(Reference),
>>> obviously because the button "MyButton" doesn't exist yet.
>>>
>>> So how can I add my event handler programmatically to achive the same
>>> effect as in 1.)?
>>>
>>>
>>>
>>> Regards
>>>
>>> R4DIUM
>>>
>>>
>>>
>>>
>
>