Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Codebehind vs inline javascript

Reply
Thread Tools

Codebehind vs inline javascript

 
 
JJ
Guest
Posts: n/a
 
      07-28-2006
Hi All,

what is the difference of me putting in this onclick event in the
actual asp.net page as such
onclick="checkFieldStatus(document.forms[0].ctxtMCAmt, this.checked);"

compared to me putting this,
cbMC.Attributes.Add("onclick", "checkFieldStatus('ctxtMCAmt.ClientID',
this.checked);");

in the codebehind? What do I gain by registering this attribute in code
behind? I added this to a checkbox control by the way and wanted to
disable the another field once checkbox is not clicked.

Thanks,
JammingJ

 
Reply With Quote
 
 
 
 
cannontrodder
Guest
Posts: n/a
 
      07-28-2006
In effect, there isn't much difference.

The second method is preferable as asp.net will ensure the client id is
properly set. Also, it keeps your application that little bit more
browser independent. In my opinion, it is easier to read and keeps
functionality separate from design markup.
JJ wrote:
> Hi All,
>
> what is the difference of me putting in this onclick event in the
> actual asp.net page as such
> onclick="checkFieldStatus(document.forms[0].ctxtMCAmt, this.checked);"
>
> compared to me putting this,
> cbMC.Attributes.Add("onclick", "checkFieldStatus('ctxtMCAmt.ClientID',
> this.checked);");
>
> in the codebehind? What do I gain by registering this attribute in code
> behind? I added this to a checkbox control by the way and wanted to
> disable the another field once checkbox is not clicked.
>
> Thanks,
> JammingJ


 
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
Inline Code (i.e. no codebehind) and Wilson's Master Pages (.Net 1.1) gr8oblivion ASP .Net 0 04-16-2007 12:17 AM
Mix Inline and Codebehind? xenophon ASP .Net 1 01-20-2006 04:37 AM
DataGrid Efficency of setting embeded control properties inline or with codebehind Earl Teigrob ASP .Net 1 07-09-2004 03:56 PM
codebehind with no inline Gary Brewer ASP .Net 1 01-23-2004 01:16 PM
inline or not to inline in C++ Abhi C++ 2 07-03-2003 12:07 AM



Advertisments