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 onchange
client side event. An example :
<select id="htmlserverselect" runat="server" onchange="alert(this.value);">
<option value="1">Yes</option>
<option value="2">No</option>
</select>
It depends a lot of times on the control you are working with and the attribute. I know that ASP button
controls will show the onclick
and the onclientclick
attributes in intellisense. It may be that ASP.NET doesn't fully support the onClick
attribute for the listitem
(as opposed to say the selectedindexchanged
attribute on the listbox
/dropdownlist
/etc controls)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With