How to disabled the input,textarea,select using this code..

Posted by kumar on Stack Overflow See other posts from Stack Overflow or by kumar
Published on 2010-06-05T22:38:07Z Indexed on 2010/06/05 22:42 UTC
Read the original article Hit count: 973

Filed under:

Hello friends I am using this code in my view..

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NorthernTrust.ATP.iTool.Core.Business.Entities.Exceptions.PricingMassEditBE>" %>

<script type="text/javascript">
    $("#PricingEditExceptions").find("input, select,textarea").attr('disabled', 'disabled');
</script>

<%var a = Model; %>
<fieldset id="PricingEditExceptions">
    <div class="fiveper">
    <label>FM#: <span><%=(null != a) ? Model.Asset.FundmasterSec : null%></span></label>
        <label>TNT#:<span><%=(null != a) ? Model.Asset.TNTSecurity: null%></span></label>
        <label>CUSIP#: <span><%=(null != a) ? Model.Asset.CUSIP :null%></span></label>
        <label>Asset:<span><%=(null != a) ? Model.Asset.AssetClassCode: null%></span></label>
         <label>Issue:<span><%=(null != a) ? Model.Asset.IssueType: null%></span></label>
          <label>COQ:<span><%=(null != a) ? Model.Asset.CodeCountryofQuotationName: null%></span></label>
          <label>CCY:<span><%=(null != a) ? Model.Asset.CurrencyCode: null%></span></label>
        <label>&nbsp;</label>
     </div>
     <div class="fiveper">   
         <input id="check1" type="checkbox" name="PMchk" value="<%=Model.ExceptionID%>" />
        <label>ID#: <span><%=(null != a) ? Model.ExceptionID : 0%></span></label>
        <label for="ExceptionStatus">
         Status: <span id="gui-stat-<%=Model.ExceptionID %>">
    <%=Model.LookupCodes["C_EXCPT_STAT"].FirstOrDefault(model => model.Key.Trim().Equals(Model.ExceptionStatus.Trim())).Value%></span>        
        </label>
         <label for="ResolutionCode">
            Resolution:
            <span>
            <%=Html.DropDownListFor(model => model.ResolutionCode, new SelectList(Model.LookupCodes["C_EXCPT_RESL"], "Key", "Value", (null != Model.ResolutionCode) ? Model.ResolutionCode.Trim() : Model.ResolutionCode))%>
            </span>
        </label>
         <label for="ReasonCode">
            Reason:
            <span><%=Html.DropDownListFor(model => model.ReasonCode, new SelectList(Model.LookupCodes["C_EXCPT_RSN"], "Key", "Value", (null != Model.ReasonCode) ? Model.ReasonCode.Trim() : Model.ReasonCode))%></span>
        </label>
        <label>Action Taken:<span><%=Html.DropDownListFor(model => model.ActionCode, new SelectList(Model.LookupCodes["C_EXCPT_ACT"], "Key", "Value", (null != Model.ActionCode) ? Model.ActionCode.Trim() : Model.ActionCode))%></span></label>
        <label>&nbsp;</label>
       </div>
        <div class="fiveper">
          <label>Follow-Up:<span class="datepicker-container"><input type="text" id="exc-flwup-<%=Model.ExceptionID %>" name="exc-flwup-<%=Model.ExceptionID %>" value="<%=Model.FollowupDate %>" /></span></label>
        <label>Inqurity #: <span><%=Html.EditorFor(model => model.IOL)%></span>
        </label>
        <label>&nbsp;</label>
        <label>Comment:
           <span>
            <%=Html.TextAreaFor(model => model.Comment, new { })%>
            <%=Html.ValidationMessageFor(model => model.Comment)%>
            </span>
        </label>
        </div>
        <div id="hide" style="display:none">
        <label><span><%=Model.Sequence %></span></label>
        <label><span><%=Model.AssignedId %></span></label>
               <span id="gui-stat-<%=Model.ExceptionID%>">
    <%=Model.LookupCodes["C_EXCPT_STAT"].FirstOrDefault(model => model.Key.Trim().Equals(Model.ExceptionStatus.Trim())).Value%></span>    
                <span>Last Updated:</span>
                <%=Model.LastUpdateUser.StartsWith("ATPB") ? "SYSTEM" : Model.LastUpdateUser%><br />
                <%=Model.LastUpdated%>
                <% if (DateTime.Now.Date == Model.LastUpdated.Value .Date )
                  {%>
                <%=Math.Round((DateTime.Now - (DateTime)Model.LastUpdated).TotalHours, 0)%> hr<%} %>   
                 <p>
       <%=Html.EditorFor(model => model.SequenceDateTimeAsString)%>
        <%=Html.EditorFor(model => model.AssignedId)%>
        <span><%=Html.EditorFor(model => model.Origination)%></span>
    </p>
        </div>
</fieldset>

<script type="text/javascript">
    $(document).ready(function() {
        function validate_excpt(formData, jqForm, options) {
            var form = jqForm[0];
        }
        // post-submit callback 
        function showResponse(responseText, statusText, xhr, $form) {
            if (responseText.substring(0, 16) != "System.Exception") {
                $('#error-msg-<%=Model.ExceptionID %> span:last').html('<strong>Update successful.</strong>');
            } else {
                $('#error-msg-<%=Model.ExceptionID %> span:last').html('<strong>Update failed.</strong> ' + responseText.substring(0, 48));
            }
            $('#error-msg-<%=Model.ExceptionID %>').removeClass('hide');
            $('#gui-stat-<%=Model.ExceptionID %>').html(responseText[1]); 
        }

        $('#exc-<%=Model.ExceptionID %>').ajaxForm({
            target: '#error-msg-<%=Model.ExceptionID %>',
            beforeSubmit: validate_excpt,
            success: showResponse,
            dataType: 'json'
        }).enable(<%=Model.EnableEdit.ToString().ToLower() %>);
       $("input[id^='exc-flwup-']").datepicker({
            duration: 0,
            buttonImage: '/Content/images/calender.gif',
            buttonImageOnly: true, 
            showOn:'button',
            constrainInput: true,
            showTime: true,
            stepMinutes: 30,
            stepHours: 1,
            altTimeField: '',
            time24h: true,
            minDate: 0
        });
         $("input[id^='exc-flwup-<%=Model.ExceptionID%>']").click(function() {
            $(this).val('');
         });
        $('#ui-timepicker-div').bgiframe();
    });
</script> 

Using this code I am disabling the fields when the view loads.. like this my view displyas for number of users which I am going to selct using this below code I am able to disable only first Fiedset not for other fieldsets?

$("#Fieldset1").find("input, select,textarea").attr('disabled', 'disabled');

why its happening? I need to disable for how many users I select....

thanks..

© Stack Overflow or respective owner

Related posts about jQuery