javascript - Adding "onclick" attribute to asp.net dropdownlist item -
I can add an attribute in the objects of a radio button list such as:
PaymentMethodDropDownList Items [0]. Features. Add ("onclick", "javascript: chonoimension ();"); PaymentMethodDropDownList.Items [1]. Features. Add ("OnClick", "Javascript: Show Credit Cardmath (";);); PaymentMethodDropDownList.Items [2]. Features. Add ("OnClick", "Javascript: ShoSaid Payment Method ();"); However, when I try to add attributes in the dropdown list control, it does not seem to work. I hope it will be similar.
This can not be similar to the radio button list, a dropdown list, the name of the correct attribute event "Onclick Instead of "Onge", the event should be linked to the dropdown list and these items are not as follows:
PaymentMethodDropDownList.Attributes.Add ("onchange", "showCreditCardMethod ();"); In addition, it is a bit more complex and requires a custom JavaScript function to perform different actions depending on the chosen option. Here's an example: PaymentMoDDropDownList.Features. Add ("On Change", "Hand Dropdown Events (This);");
Custom javascript function: It assumes that the value for the dropdown item is "credit card" and "despatch payment".
& lt; Script type = "text / javascript" & gt; Function handleDropDownAvent (E) {if (e.value == "credit card") {showCreditCardMethod (); } And if (e.value == "Send Payment") {showSendPaymentMethod (); }} & Lt; / Script & gt;
Comments
Post a Comment