473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Codebehind vs inline javascript

JJ
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

Jul 28 '06 #1
1 1061
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
Jul 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gary Brewer | last post by:
Hi, I often find myself creating ASPX pages in VS.NET that have no 'content' in the aspx page but normally just have code in the code behind page. For example, I use this method when I want to...
2
by: Ekken Zuiber | last post by:
hiye people, i know this have been ask multipletimes over the past year, but i cant find any here in the new group so here goes.. in my code behind, i'm going to do some validation and use...
1
by: Earl Teigrob | last post by:
I have a DataGrid that needs to set many properites on its embeded controls in the ItemTemplate and EditItemTemplate Templates. I have a choice between using the inline <%# %> or the OnItemCreated...
5
by: Arne | last post by:
I have been doing code behind pages in ASP.Net for about two years. Now I need to debug a production page. I would like to move all the code from the code behind page and into the contact.aspx...
5
by: GaryDean | last post by:
I have a 1.1 asp.net project that has been converted by the conversion wizard. By and large the app runs allright except for one page... On one of the .aspx pages, the code behind file is not...
1
by: xenophon | last post by:
I want to set my ASP.NET 2.0 project to 1.1-style comiplation, with all of my code-behind placed into a single .DLL. I also want to support inline coding in the ASP.NET 2.0 .aspx, so junionr...
6
by: antonyliu2002 | last post by:
Right now I put my VB code in the aspx pages. I would prefer to use codebehind, especially many of my VB functions may be shared across multiple aspx pages. I've tried a few pages with...
0
by: gr8oblivion | last post by:
Hi everyone, I'm using .Net 1.1 to create a c# web application... and I want to use Wilson's Master Pages. The problem is, I'm planning on hosting it on Brinkster which does not allow...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.