c# - Calling Javascript function from an asp dropdownlist -
i have asp dropdownlist few selections , when select item list want javascript modal open up. have been able open modal using html button after selecting specific item drop down, want 1 less step.
here code index changed event on drop down:
protected void shipto_changed(object sender, eventargs e) { foreach (datalistitem dli in cart.items) { dropdownlist drpshipto = (dropdownlist)dli.findcontrol("drpshipto"); if (drpshipto.selecteditem.text == "-add new shipto-") { page.clientscript.registerstartupscript(this.gettype(), "function", "showdialog('newshipto')", true); } } }
and here have js :
<script> $(document).ready(function () { $('#newshipto').dialog({ autoopen: false, draggable: true, title: "add new shipto", open: function (type, data) { $(this).parent().appendto("form"); } }); $('#editshipto').dialog({ autoopen: false, draggable: true, title: "edit shipto", open: function (type, data) { $(this).parent().appendto("form"); } }); }); function showdialog(id) { $('#' + id).dialog("open"); } function closedialog(id) { $('#' + id).dialog("close"); } </script>
i know function works, can swap out phone call function making button visible onclick set showdialog('newshipto')
am not calling correctly using registarstartupscript
i going take stab @ answering.
in drop down....add onchange event calling showdialog('newshipto')
javascript c# asp.net
No comments:
Post a Comment