zoukankan      html  css  js  c++  java
  • RadioButtonList根据值触发OnSelectedIndexChanged事件

    Insus.NET有使用Iframe来处理另外一个站点的enter form,由于需要自动循环填入数据,免去人手操作。但是原来的Enter from有RadioButtonList控件以及OnSelectedIndexChanged关联另外一个DropDownList控件。这样的话,问题来了,怎样根据与指定RadioButtonList的值之后,并触发其OnSelectedIndexChanged事件?

    先来看看原aspx的代码:

    <asp:radiobuttonlist id=rdblstLocationCategory runat="server"


    运行浏览查看源代码:

     <span id="rdblstLocationCategory">
            <input id="rdblstLocationCategory_0" type="radio" name="rdblstLocationCategory" value="Cutter    " onclick="__doPostBack('rdblstLocationCategory_0', '')" language="javascript" /><label for="rdblstLocationCategory_0">Cutter    </label>
            <input id="rdblstLocationCategory_1" type="radio" name="rdblstLocationCategory" value="FQA       " onclick="__doPostBack('rdblstLocationCategory_1', '')" language="javascript" /><label for="rdblstLocationCategory_1">FQA       </label>
            <input id="rdblstLocationCategory_2" type="radio" name="rdblstLocationCategory" value="WIP       " checked="checked" onclick="__doPostBack('rdblstLocationCategory_2', '')" language="javascript" /><label for="rdblstLocationCategory_2">WIP       </label>
        </span>


    它有三个选项,也生成了三个input,而input的Id的值,也变成了rdblstLocationCategory_X。最后一个数字就是从0开始,直至选项总数减1止。

    刚开始,Insus.NET是能解决了为RadioButtonList设置一个默认值,但是指值让其选中之后,怎样让其触发OnSelectedIndexChanged事件呢?,确实是需要动点脑筋。

    由于Insus.NET是使用了jQuery来开发。这个是有关事件方面的问题,然后从jQuery的事件入手,最后发现了一个叫.triggerHandler()事件。它触发被选元素的指定事件类型。但不会执行浏览器默认动作,也不会产生事件冒泡。

    因此Insus.NET的解决方法,就可以实现为,下例中是指定第三个选项为指值:



    学习jQuery,了解它很重要,但会运行它还是更加重要。

  • 相关阅读:
    第八章 多线程编程
    Linked List Cycle II
    Swap Nodes in Pairs
    Container With Most Water
    Best Time to Buy and Sell Stock III
    Best Time to Buy and Sell Stock II
    Linked List Cycle
    4Sum
    3Sum
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/insus/p/3523778.html
Copyright © 2011-2022 走看看