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 </htmltag everything works fine.
2.) If I write this code as a javascript block between the <headtags 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 3 2741
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',my func);",
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 </htmltag everything works fine.
2.) If I write this code as a javascript block between the <headtags 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
Thx - where exactly do I register the js-file which contains my "myfunc" ?
Regards
R4DIUM
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plschrieb im Newsbeitrag
news:D4**********************************@microsof t.com...
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',my func);",
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"),"clic k",myfunc);
function myfunc(event)
{
alert("Hi!");
}
1.) If I write this code as a javascript block after the page under the closing </htmltag everything works fine.
2.) If I write this code as a javascript block between the <headtags 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
Is there a possibility to have the
Sys.UI.DomEvent.addHandler($get('ButtonID'),'click ',myfunc) in a file as
well?
Regards
RADIUM
"Axel Gallus" <uh**@rz.uni-karlsruhe.deschrieb im Newsbeitrag
news:fn**********@news2.rz.uni-karlsruhe.de...
Thx - where exactly do I register the js-file which contains my "myfunc" ?
Regards
R4DIUM
"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plschrieb im
Newsbeitrag news:D4**********************************@microsof t.com...
>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',my func);", 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"),"cli ck",myfunc);
function myfunc(event)
{
alert("Hi!");
}
1.) If I write this code as a javascript block after the page under the closing </htmltag everything works fine.
2.) If I write this code as a javascript block between the <headtags 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Clarence Gardner |
last post by:
I'm seeing surprising behavior, consistent across Opera, Firefox, and IE.
An event handler is changing the value of an element, and there is apparently
no Change event being generated for the...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that...
|
by: Tim Marsden |
last post by:
Hi,
This is what I am doing, please comment if this is the correct way.
I need to add controls to a form dynamically.
Within the Page_Load event (is not Postback) I run a routine to create the...
|
by: Kurt |
last post by:
Hi Brent,
I don't know if this is best practices per se`, but it
works.
The following generates a new button control each time
menu item 1 is clicked and assigns an event handler to
it. ...
|
by: Neo Geshel |
last post by:
I have strip-mined, strip-searched, and completely exhausted the
Internet (up to the 30th page on Google, with 100 results per page!!),
all without finding an answer to my question AS TO WHY IT...
|
by: Oleg Subachev |
last post by:
I need to programmatically invoke from other class
Click event of the Button on my Form.
Button.OnClick method is protected, not public.
How to perform this ?
Oleg Subachev
|
by: Bob |
last post by:
Hi,
I'm working with VWD and i defined programmatically a button (in
code-behind) with an ID. So I expect to see beside "Page Events" and "Form1"
my button "b1" in order to use the Click event....
|
by: ChrisCicc |
last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
|
by: SAL |
last post by:
hello,
I'm using a radiobuttonlist in an updatepanel in an item template in a
Gridview control. I'm populating the radiobuttonlist in the RowDataBound
event. I have the control toolkit registered...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |