Connecting Tech Pros Worldwide Forums | Help | Site Map

aspx web form controls and client side java script

Rea Peleg
Guest
 
Posts: n/a
#1: Nov 18 '05
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..



Dale
Guest
 
Posts: n/a
#2: Nov 18 '05

re: aspx web form controls and client side java script


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


"Rea Peleg" <reapeleg@barak-online.net> wrote in message
news:evdUYvpcEHA.996@TK2MSFTNGP12.phx.gbl...[color=blue]
> 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..
>
>[/color]


Jeffrey Palermo [MCP]
Guest
 
Posts: n/a
#3: Nov 18 '05

re: aspx web form controls and client side java script


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

"Dale" <daleDeletepres@msndotcomNot.Net> wrote in message
news:u$uv3ArcEHA.3040@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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
>
>
> "Rea Peleg" <reapeleg@barak-online.net> wrote in message
> news:evdUYvpcEHA.996@TK2MSFTNGP12.phx.gbl...[color=green]
> > 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[/color][/color]
aspx[color=blue][color=green]
> > web form.
> > This function is called on selectedIndexChanged event of server side[/color][/color]
radio[color=blue][color=green]
> > button list,
> > but i can not get there . During compilation, it seems like the dotnet[/color][/color]
asp[color=blue][color=green]
> > service is looking for this function on that web form's (server side)[/color][/color]
code[color=blue][color=green]
> > 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..
> >
> >[/color]
>
>[/color]


Closed Thread