Working with OnClientSelectedIndexChanged and javascript

2 posts, 0 answers
  1. JFB
    JFB avatar
    6 posts
    Member since:
    Oct 2012

    Posted 02 Apr 2012 Link to this post

    How can I retrieve a hidden asp:Label field when the OnClientSelectedIndexChanged event is raised?

    javascript:
    function OnClientSelectedIndexChanged(sender, eventArgs) {
        var item = eventArgs.get_item();
        if (item.get_text() == "Rejected") {
            var WorkItemId = [...]
            OpenReasonWindow(workItemId);
        }
    }


    markup:
    <tr id="ctl00_PageContent_rtlRshItems_ctl04__2" class="rtlR rtlRL" style="background-color:Lavender;">
     
    <td align="left" valign="middle" style="width:90px;">
        <div id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatus" class="RadComboBox RadComboBox_Windows7">
            <table class="rcbFocused" style="border-width: 0pt; border-collapse: collapse;" summary="combobox">
                <tbody>
                    <tr class="rcbReadOnly">
                        <td class="rcbInputCell rcbInputCellLeft" style="width:100%;">
                            <input id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatus_Input" class="rcbInput" type="text" readonly="readonly" value="Submitted" name="ctl00$PageContent$rtlRshItems$ctl04$rcbStatus" autocomplete="off">
                        </td>
                        <td class="rcbArrowCell rcbArrowCellRight">
                            <a id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatus_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a>
                        </td>
                    </tr>
                </tbody>
            </table>
     
            <input id="ctl00_PageContent_rtlRshItems_ctl04_rcbStatus_ClientState" type="hidden" name="ctl00_PageContent_rtlRshItems_ctl04_rcbStatus_ClientState" autocomplete="off">
        </div>
    </td>
     
    <td class=" rtlCL" style="width:0px;">
        <asp:label id="lblWorkItemId" text="199" visible="false"> </asp:label>
    </td>

    I want to obtain the value of lblWorkItemId, how can I do this?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Apr 2012 Link to this post

    Hi,

    Its not possible to access the label in JavaScript when Visible property is set to False. Instead of setting Visible to false please try setting display to none. Please take a look into the following sample.

    ASPX:
    <asp:label id="lblWorkItemId" text="199"  runat="server" style="display:none"  > </asp:label>

    JS:
    function OnClientSelectedIndexChanged(sender, eventArgs)
     {
        var item = eventArgs.get_item();
        if (item.get_text() == "Rejected")
        {
            var WorkItemId =  document.getElementById("lblWorkItemId");
            OpenReasonWindow(workItemId);
        }
     }

    Hope this helps,

    Thanks,
    Princy.
Back to Top