DropDownList控件的changed事件调用

本文介绍了ASP.NET中DropDownList控件的SelectedIndexChanged和TextChanged事件的使用方法。为了使这两个事件能够被自动触发,需要将控件的AutoPostBack属性设置为true。文章通过具体的代码示例展示了如何正确配置这些事件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DropDownList控件的SelectedIndexChanged和TextChanged事件调用必须首先把该控件的AutoPostBack属性设置为true,否则该事件在应用时无法自动触发!

    <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True">
    </asp:DropDownList>

    <asp:DropDownList ID="DropDownList1" runat="server"
            onselectedindexchanged="DropDownList1_SelectedIndexChanged"
            ontextchanged="DropDownList1_TextChanged"
            AutoPostBack="True">
    </asp:DropDownList>

转载于:https://www.cnblogs.com/macavalier/archive/2008/10/07/1305709.html

把这段代码里面的加载morpher方式 改为自动加载: rollout morpherControl "Morpher 通道控制器" width:300 height:400 ( -- 界面元素 dropdownlist ddlTargets "目标对象:" items:(for obj in objects collect obj.name) height:15 dropdownlist ddlMorphers "Morpher修改器:" items:#() height:10 spinner spnChannel "通道编号:" range:[1,100,1] type:#integer fieldWidth:40 spinner spnWeight "权重值:" range:[0.0,100.0,0.0] type:#float fieldWidth:50 slider sldWeight "权重控制" range:[0,100,0] ticks:10 button btnApply "应用权重" listbox lbxChannels "可用通道" height:10 -- 定义函数(放在事件之前) fn updateChannelList = ( if ddlTargets.selection > 0 and ddlMorphers.selection > 0 do ( local targetObj = getNodeByName ddlTargets.items[ddlTargets.selection] local morpherMod = targetObj.modifiers[ddlMorphers.items[ddlMorphers.selection]] if morpherMod != undefined and classOf morpherMod == Morpher do ( local channelNames = #() for i = 1 to 100 where (WM3_MC_HasData morpherMod i) do ( append channelNames (i as string + ": " + (WM3_MC_GetName morpherMod i)) ) lbxChannels.items = channelNames ) ) ) fn updateWeightDisplay chanIndex = ( if ddlTargets.selection > 0 and ddlMorphers.selection > 0 and chanIndex > 0 do ( local targetObj = getNodeByName ddlTargets.items[ddlTargets.selection] local morpherMod = targetObj.modifiers[ddlMorphers.items[ddlMorphers.selection]] if morpherMod != undefined and classOf morpherMod == Morpher do ( local weight = WM3_MC_GetValue morpherMod chanIndex spnWeight.value = weight sldWeight.value = weight ) ) ) fn applyWeight chanIndex weight = ( if ddlTargets.selection > 0 and ddlMorphers.selection > 0 and chanIndex > 0 do ( local targetObj = getNodeByName ddlTargets.items[ddlTargets.selection] local morpherMod = targetObj.modifiers[ddlMorphers.items[ddlMorphers.selection]] if morpherMod != undefined and classOf morpherMod == Morpher do ( if (WM3_MC_HasData morpherMod chanIndex) then ( WM3_MC_SetValue morpherMod chanIndex weight completeRedraw() ) else ( messageBox "选定的通道没有有效数据!" ) ) ) ) -- 事件处理 on ddlTargets selected sel do ( local targetObj = getNodeByName ddlTargets.items[sel] if isValidNode targetObj do ( local morpherList = #() for mod in targetObj.modifiers where classOf mod == Morpher do ( append morpherList mod.name ) ddlMorphers.items = morpherList if morpherList.count > 0 then ddlMorphers.selection = 1 ) ) on ddlMorphers selected sel do updateChannelList() on lbxChannels selected sel do ( spnChannel.value = sel updateWeightDisplay sel ) on spnWeight changed val do ( sldWeight.value = val applyWeight spnChannel.value val ) on sldWeight changed val do ( spnWeight.value = val applyWeight spnChannel.value val ) on btnApply pressed do applyWeight spnChannel.value spnWeight.value ) createDialog morpherControl
最新发布
07-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值