javascript properties .net properties
Could you please compare the properties
I want t开发者_如何学Co disable a text box 'txtName'. There are two ways
- Use javascript,
txtName.disabled = true
- Use ASP.NET ,
<.. Enabled="false" ..>
Which method is better and Why?
I assume Enabled="false"
results in disabled="disabled"
in the generated HTML code. In this case that's clearly the better way as it doesn't require the user to have JavaScript enabled.
If you want to disable a button, the server side method would require a round trip (postback of the page, event handlers run, response returned).
The client side method (javascript) does not require this.
However, if javascript is disables, the client side method will not work.
In either case, the end result is the same (the disabled
attribute is set).
There is no difference.
精彩评论