Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Control Events renamed in ASPX - What a shame (http://www.velocityreviews.com/forums/t121614-control-events-renamed-in-aspx-what-a-shame.html)

Mikeon 03-15-2006 10:06 AM

Control Events renamed in ASPX - What a shame
 
Hello!

Today it came to me that ASP.NET has a special "feature" that takes an
event name defined on a control and adds the "On" prefix for it when it
is used in the ASPX file ie.: when you use the Button control, to wire
up the Click event you have to use the OnClick event.
Now that is a shame! Why ASP.NET changes the names of my events and
only in ASPX file (in the code behind the same event is named
correctly)?
I can see only problems that result from this one of the most obvious
is that it is not possible to define a client side "onclick" event for
the button, because ASP.NET already uses this name for my Click (!!!)
event.

Is there at least one GOOD reason why ASP.NET does what it does in a
way it is doing it?

--
Michal


Bruce Barker 03-15-2006 06:04 PM

Re: Control Events renamed in ASPX - What a shame
 
the orignal design of asp.net was to avoid client code, and to match winform
syntax thru abstract controls. now that ajax has made client code popular
again, this is somewhat an issue. the next release will have ajax aware
controls that makes linking client script less messy.

-- bruce (sqlwork.com)


"Mikeon" <mikeon@icpnet.pl> wrote in message
news:1142417178.236533.84540@j33g2000cwa.googlegro ups.com...
> Hello!
>
> Today it came to me that ASP.NET has a special "feature" that takes an
> event name defined on a control and adds the "On" prefix for it when it
> is used in the ASPX file ie.: when you use the Button control, to wire
> up the Click event you have to use the OnClick event.
> Now that is a shame! Why ASP.NET changes the names of my events and
> only in ASPX file (in the code behind the same event is named
> correctly)?
> I can see only problems that result from this one of the most obvious
> is that it is not possible to define a client side "onclick" event for
> the button, because ASP.NET already uses this name for my Click (!!!)
> event.
>
> Is there at least one GOOD reason why ASP.NET does what it does in a
> way it is doing it?
>
> --
> Michal
>




Joey 03-16-2006 02:51 PM

Re: Control Events renamed in ASPX - What a shame
 
Michal, the model in asp.net 2.0 is to provide handlers for BOTH client
side and server side. Buttons now have OnClick for server events and
OnClientClick for client-side. In my opinion, this is actually a very
good thing!

Quick example here:

http://www.c-sharpcorner.com/Code/20...edControls.asp

JP



All times are GMT. The time now is 09:35 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.