Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > OnClick vs InitializeComponent()

Reply
Thread Tools

OnClick vs InitializeComponent()

 
 
Mikael Janers
Guest
Posts: n/a
 
      11-24-2003
Hi!

When you want a serverside event on for example an asp:ImageButton... Whats
the difference between using OnClick="..." and binding the event in the
InitializeComponent() method ?


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      11-25-2003
The other (OnClick="handler") is a way to specify it declaratively, whereas
in code-behind (InitializeComponent or somewhere else before the events is
raised) it is a dynamic one. From functionality standpoint no difference,
but from application design yes as the latter is a way to hide the
implementation from the UI.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Mikael Janers" <nospam> wrote in message
news:(E-Mail Removed)...
> Hi!
>
> When you want a serverside event on for example an asp:ImageButton...

Whats
> the difference between using OnClick="..." and binding the event in the
> InitializeComponent() method ?
>
>



 
Reply With Quote
 
 
 
 
Mikael Janers
Guest
Posts: n/a
 
      11-25-2003
Okay thanks!, but I dont buy that the InitializeComponent would be any
better at hiding the implementation... You are still bound by the components
id in the aspx file ?. To me both methods are equaly sensitive if someone
messes with the aspx file. Either you are bound by the ID or by the OnClick
?

"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The other (OnClick="handler") is a way to specify it declaratively,

whereas
> in code-behind (InitializeComponent or somewhere else before the events is
> raised) it is a dynamic one. From functionality standpoint no difference,
> but from application design yes as the latter is a way to hide the
> implementation from the UI.
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
>
> "Mikael Janers" <nospam> wrote in message
> news:(E-Mail Removed)...
> > Hi!
> >
> > When you want a serverside event on for example an asp:ImageButton...

> Whats
> > the difference between using OnClick="..." and binding the event in the
> > InitializeComponent() method ?
> >
> >

>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      11-26-2003
It's not necessarily security caution, but logical caution say to improve
reusability, readability and structure of the code. Basically yes, ID or
attribute is the way (because of code-behind mechanism where dynamic page
class i.e aspx class inherits from the code-behind class so members must
match).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


"Mikael Janers" <nospam> wrote in message
news:(E-Mail Removed)...
> Okay thanks!, but I dont buy that the InitializeComponent would be any
> better at hiding the implementation... You are still bound by the

components
> id in the aspx file ?. To me both methods are equaly sensitive if someone
> messes with the aspx file. Either you are bound by the ID or by the

OnClick
> ?
>
> "Teemu Keiski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > The other (OnClick="handler") is a way to specify it declaratively,

> whereas
> > in code-behind (InitializeComponent or somewhere else before the events

is
> > raised) it is a dynamic one. From functionality standpoint no

difference,
> > but from application design yes as the latter is a way to hide the
> > implementation from the UI.
> >
> > --
> > Teemu Keiski
> > MCP, Microsoft MVP (ASP.NET), AspInsiders member
> > ASP.NET Forum Moderator, AspAlliance Columnist
> >
> > "Mikael Janers" <nospam> wrote in message
> > news:(E-Mail Removed)...
> > > Hi!
> > >
> > > When you want a serverside event on for example an asp:ImageButton...

> > Whats
> > > the difference between using OnClick="..." and binding the event in

the
> > > InitializeComponent() method ?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Mikael Janers
Guest
Posts: n/a
 
      11-26-2003
Oki, thanks very much for the feedback!

"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It's not necessarily security caution, but logical caution say to improve
> reusability, readability and structure of the code. Basically yes, ID or
> attribute is the way (because of code-behind mechanism where dynamic page
> class i.e aspx class inherits from the code-behind class so members must
> match).
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
>
>
> "Mikael Janers" <nospam> wrote in message
> news:(E-Mail Removed)...
> > Okay thanks!, but I dont buy that the InitializeComponent would be any
> > better at hiding the implementation... You are still bound by the

> components
> > id in the aspx file ?. To me both methods are equaly sensitive if

someone
> > messes with the aspx file. Either you are bound by the ID or by the

> OnClick
> > ?
> >
> > "Teemu Keiski" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > The other (OnClick="handler") is a way to specify it declaratively,

> > whereas
> > > in code-behind (InitializeComponent or somewhere else before the

events
> is
> > > raised) it is a dynamic one. From functionality standpoint no

> difference,
> > > but from application design yes as the latter is a way to hide the
> > > implementation from the UI.
> > >
> > > --
> > > Teemu Keiski
> > > MCP, Microsoft MVP (ASP.NET), AspInsiders member
> > > ASP.NET Forum Moderator, AspAlliance Columnist
> > >
> > > "Mikael Janers" <nospam> wrote in message
> > > news:(E-Mail Removed)...
> > > > Hi!
> > > >
> > > > When you want a serverside event on for example an

asp:ImageButton...
> > > Whats
> > > > the difference between using OnClick="..." and binding the event in

> the
> > > > InitializeComponent() method ?
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overriding an onclick with another onclick tomlong@gmail.com Javascript 4 01-26-2006 09:26 PM
button.onclick = new Function("func2()") + button.onclick foldface@yahoo.co.uk Javascript 2 09-26-2005 08:13 AM
ToolbarCheckButton - no onclick property? ASP .Net 1 05-23-2005 12:36 PM
Problem onClick event on Firefox orion30 Firefox 0 11-07-2004 02:34 PM
document.onclick=doIt() same as document.onclick=doIt ? bob Javascript 3 08-21-2003 12:14 PM



Advertisments