aspx web form controls and client side java script

R

Rea Peleg

Hi all

Is it possible to handle web controls events on client side???

I wrote a simple favascript function inside the <header> area of an aspx
web form.
This function is called on selectedIndexChanged event of server side radio
button list,
but i can not get there . During compilation, it seems like the dotnet asp
service is looking for this function on that web form's (server side) code
behind instead
(this control's autoPostBack property is also set to false).
Am i right??

If so should i use regular html controls when i need to handle events on
client side?

I'm not sure i understand the advantage of using server side controls if
this is the case..
 
D

Dale

Assuming your DropDownList is ddl1, add this in your Page_Load():

ddl1.Attributes.Add("onchange", "myJavaScriptMethod(this)");

That'll do it for you.

Dale Preston
MCAD, MCSE, MCDBA
 
J

Jeffrey Palermo [MCP]

Rea,
You don't need server controls in all cases. If you are populating the
combo box programmatically, then it'll need to be a server control. If not,
then just make it a regular html control and set onchange="myFunc(this);",
but if it's a server control, then follow Dale's suggestion. This puts that
onchange attribute there for you.

Best regards,
Jeffrey Palermo
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top