tags:

views:

841

answers:

1

I have a DropDownList as a custom control inserted into a subform which is within a popup window on my main page. I have coded unique CssClass identifiers for both the DropDownList and the textbox I am trying to enable/disable. I only want the textbox enabled for DropDownList values 317 and 318, all others should disable the textbox. Here is the problem... If I bring up my popup window and select an action other than 317/318, it disables the textbox as expected. Then if I change my mind and select 317 or 318 it DOES NOT enable the textbox. This seems real strange that it partially works.

I have the following jquery code in my main page:

<script language="javascript" type="text/javascript">

     var _CASE_RESERVE_ACTION = "317"; 
     var _LEGAL_RESERVE_ACTION = "318";

     function pageLoad() {

         $(".statusActionDDLCssClass").change(function() {
             var value = $(this).val();
             if (value == _CASE_RESERVE_ACTION || value == _LEGAL_RESERVE_ACTION)
                 $(".statusActionAmountCssClass").attr('enabled', 'enabled');
             else
                 $(".statusActionAmountCssClass").attr('disabled', 'disabled');
         });
     }

</script>

Here is the custom control with the DropDownList:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="StStatusActionLookup.ascx.cs" Inherits="Company.Solutions.Web.Controls.StStatusActionLookup" %>

<div id="mainControlContainer" style="width:99%; padding:8px;">

    <div id="comboContainer" style="float:left; padding-top:12px;padding-left:5px; padding-right:5px; padding-bottom:3px;">
        <asp:UpdatePanel ID="update1" runat="server" UpdateMode="Always">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="chkComments" EventName="CheckedChanged" />
                <asp:AsyncPostBackTrigger ControlID="chkDenials" EventName="CheckedChanged" />
                <asp:AsyncPostBackTrigger ControlID="chkOther" EventName="CheckedChanged" />
            </Triggers>
            <ContentTemplate>
                <asp:DropDownList runat="server" ID="ddlLookup" width="240px" CssClass="statusActionDDLCssClass" />
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>
    <div id="filterContainer" style="text-align:left;padding-left:6px;width:275px">
        <fieldset style="width:260;">
            <legend>Filters</legend>
            <asp:CheckBox ID="chkComments" runat="server" Text="Comments" AutoPostBack="true"  />
            <asp:CheckBox ID="chkDenials" runat="server" Text="Denials" AutoPostBack="true" />
            <asp:CheckBox ID="chkOther" runat="server" Text="Other" AutoPostBack="true" />
        </fieldset>

    </div>    
</div>

And here is my subform with the text box (txtStatusActionAmount):

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="StatusActionAddSubform.ascx.cs" 
Inherits="Company.Solutions.Web.Controls.StatusActionAddSubform" %>
<%@ Register TagPrefix="st" TagName="StatusActionLookup" Src="~/Controls/StStatusActionLookup.ascx" %>
<div class="NinetyNinePercentWide">
    <div class="NinetyNinePercentWide EightPixelBottomMargin">
        <div class="RowHeader" style="padding-top: 20px;">
            <span>Action:</span>
        </div>
        <div>
            <xy:StatusActionLookup ID="statusActionLookup1" runat="server" />
        </div>
    </div>
    <div class="NinetyNinePercentWide EightPixelBottomMargin">
        <div class="quarterWidthDiv">
            <span>New Status:</span>
            <asp:Literal runat="server" Text="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" ID="spc2" />
            <asp:DropDownList runat="server" ID="ddlNewStatus">
                <asp:ListItem Selected="True" Value="" Text="" />
                <asp:ListItem Value="01" Text="Open" />
                <asp:ListItem Value="02" Text="Closed" />
            </asp:DropDownList>
        </div>
        <div class="quarterWidthDiv">
            <span>Date:</span>
            <asp:Literal runat="server" Text="&nbsp;&nbsp" ID="spc1" />
            <asp:TextBox ID="txtStatusActionDate" runat="server" Columns="10" MaxLength="10"
            Style="width: 35%;" CssClass="statusActionDate" />
            <cc1:CalendarExtender ID="txtStatusActionDate_CalendarExtender" runat="server" Enabled="True"
            TargetControlID="txtStatusActionDate" />
            <cc1:MaskedEditExtender runat="server" ID="txtStatusActionDate_MaskedEditExtender"
            Enabled="True" Mask="99/99/9999" MaskType="Date" TargetControlID="txtStatusActionDate"
            UserDateFormat="MonthDayYear" />
            <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtStatusActionDate"
            Type="Date" Operator="DataTypeCheck" ErrorMessage="Invalid Date" >     </asp:CompareValidator>          
        </div>
        <div class="quarterWidthDiv">
        <asp:Label runat="server" ID="lblStatusActionAmount" AssociatedControlID="txtStatusActionAmount"
            Text="Amount:" />
            <asp:TextBox ID="txtStatusActionAmount" runat="server" Style="width: 30%;" CssClass="statusActionAmountCssClass" />
        </div>
        <div class="quarterWidthDiv">
            <asp:Label runat="server" ID="lblClaimant" AssociatedControlID="ddlClaimant" Text="Claimant:" />
            <asp:DropDownList ID="ddlClaimant" runat="server" onchange="mailOrStatusActionTextChanged()">
                <asp:ListItem Selected="True" Value="" Text="" />
                <asp:ListItem Value="1" Text="Primary" />
                <asp:ListItem Value="2" Text="Secondary" />
            </asp:DropDownList>
        </div>
    </div>
    <div  class="NinetyNinePercentWide EightPixelBottomMargin" style="margin-top: 2px;">
        <div class="RowHeader">
            <asp:Label runat="server" ID="lblStatusActionReason" AssociatedControlID="txtStatusActionReason"
            Text="Reason:" />
        </div>
        <div style="padding-left: 12px;">
            <asp:TextBox ID="txtStatusActionReason" runat="server" TextMode="MultiLine" Rows="2"
            MaxLength="25" CssClass="StatusReasonWidth" onchange="mailOrStatusActionTextChanged()" />
            <asp:CustomValidator ID="cstmValStatusActionReason" runat="server" ControlToValidate="txtStatusActionReason"
            ErrorMessage="String is too long" />
        </div>
    </div>
</div>

Thank you, Jim in Suwanee, GA

A: 

I don't believe there is a 'enabled' property of form elements, try

$(".statusActionAmountCssClass").attr('disabled', false);
jayrdub
I think a value of false will still trigger it to be disabled. The `disabled` attribute would need to be removed with either `.removeAttr('disabled')` and I think `.attr('disabled', null)` works too.
Ken Browning
Works like a champ! Thanks a bunch!if (value == _CASE_RESERVE_ACTION || value == _LEGAL_RESERVE_ACTION) $(".statusActionAmountCssClass").attr('disabled', false); else $(".statusActionAmountCssClass").attr('disabled', true);
James
I only tested it in firefox before answering, it may need to be as Ken Browning said for all other browsers, be sure to test.
jayrdub