I am just getting into more client-side stuff in ASP.NET using Javascript, and there’s something that’s bothering me that hopefully somebody can explain. Why is it that intellisense doesn’t show the all of the attributes/properties of a .NET control? For example, a ListItem in a RadioButtonListControl:
<asp:ListItem Value="1" Text="Yes" onclick="alert('TEST1');" />
<asp:ListItem Value="0" Text="No" onclick="alert('TEST2');" />
Intellisense doesn’t show the onclick property (or is it called attribute?) of the ListItem, but it sure works. Why doesn’t it show? Or am I relying on Intellisense too much? 🙂 Or should I be declaring this stuff in code-behind?
The issue is that intellisense for Web server controls does not display client side events and only lists events that are raised on the server. If you were to use an HTML server control for the same purpose you would see the (client-side JS) events in Intellisense.
Another issue to consider is that the onclick event isn’t supported for option elements (atleast not in IE, though Firefox supports it fine). You should instead handle the
onchangeclient side event. An example :