Attributes.Add doesnt work for me

S

Showjumper

I have a problem. Somecontrol.Attributes.Add is not working for me nor is
page.registerclientscriptblock. I have created a script using the
stringbuilder class. Then when i try to register it on the page in the page
load event it doesnt appear. Also i am adding in page load the onkeydown and
onkeyup attributes to a textbox set for multiline. None of these appear in
the page. I am using codebehind too. However if i change AutoEventWireup to
true then it all works as it should. I have a user control in which i add
onmouseover to an image but that has its autoeventwireup set to false and it
works. Whats the deal here? Any ideas?

thx
ashok
 
C

Craig Deelsnyder

Showjumper said:
I have a problem. Somecontrol.Attributes.Add is not working for me nor is
page.registerclientscriptblock. I have created a script using the
stringbuilder class. Then when i try to register it on the page in the page
load event it doesnt appear. Also i am adding in page load the onkeydown and
onkeyup attributes to a textbox set for multiline. None of these appear in
the page. I am using codebehind too. However if i change AutoEventWireup to
true then it all works as it should. I have a user control in which i add
onmouseover to an image but that has its autoeventwireup set to false and it
works. Whats the deal here? Any ideas?

thx
ashok

I would be suspicious of where these lines of code are being run from.
AutoEventWireup means asp.net will look for methods with certain names
such as Page_Load by default, if you don't specify handlers explicitly,
to run for your Page.Load handler, for example. So without seeing your
code, I'd assume this is a possible cause. Make sure the events or
methods where you're running this extra code are called by asp.net (are
defined as handlers of certain events).

E.g. if you're doing this setting of attributes, etc. in Page_Load, make
sure Page_Load has a Handles statement on the end of the definition of
it (if using VB.NET). Similarly for C# check to see if this.Load is set
to the proper handler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top