Page rendering asp.net DisabledCssClass

1

I have the following problem, I have this code on a page:

<div class="modal-footer">
    <asp:Button runat="server" ID="btnCancelar" Text="Cancelar" class="btn btn-sm btn-danger" data-dismiss="modal" Width="90px" />
    <asp:Button runat="server" ID="btnSalvar" Text="Gravar" class="btn btn-sm btn-primary" ClientIDMode="Static" Width="90px" OnClick="btnSalvar_Click" />
</div>

This page loads in two moments, when I will add records and when I will consult. When I edit the page, these buttons must be disabled. So I run the code in the codebehind below:

btnSalvar.Enabled = false;
btnCancelar.Enabled = false;

so this HTML elements are rendered this way:

<div class="modal-footer">
    <input type="submit" name="btnCancelar" value="Cancelar" id="btnCancelar" disabled="disabled" class="aspNetDisabled" data-dismiss="modal" style="width:90px;">
    <input type="submit" name="btnSalvar" value="Gravar" id="btnSalvar" disabled="disabled" class="aspNetDisabled" style="width:90px;">
</div>

I know that Framework 4.0 defines this style sheet "aspNetDisabled" when an element is disabled, but the problem is that it is overwriting the bootstrap css, which formats the button layout.

Do you have any settings so you do not override style classes?

    
asked by anonymous 13.01.2017 / 19:39

3 answers

0

As per Douglas Garrido commented, all I had to do was change the css tag to CssClass, which I already a lot of distraction from me not having noticed that, and I did not know that it gave that problem.

Because with rendering compatibility mode (controlRenderingCompatibilityVersion) set to 3.5, this error did not happen.

    
13.01.2017 / 20:22
0

What you can try is to put the attribute you use to

class="btn btn-sm btn-danger disabled"

and by jquery remove the class according to the actions of the user.

<script>
$( "#btnEnviar" ).onclick( function(){
    $( "#btnSalvar" ).addClass( "disabled" );
    $("#btnSalvar").removeClass("disabled");
});
</script>

You can also search the css file of the disabled class and put! important so that it can be rendered as a priority. See the options of using angularjs or jquery to manipulate the front-end, it's easier and the back-end gets bank account and business rules. With the Angular a simple indication type

 <button type="submit" class="btn btn-default btn-sm" ng-disabled="!form.$valid">Enviar</button>

ie if the form is not valid and missing a required field, this button is automatically disabled and you do not need to manipulate client-side in the back end. You can do the same with jquery, but go a bit more code.

AngularJs Documentation

    
13.01.2017 / 20:12
0

You can use the Button's CssClass property and change so that the bootstrap css is not rewritten.

btnSalvar.Enabled = false;
btnSalvar.CssClass = "btn btn-outline-secondary";
btnCancelar.Enabled = false;
btnCancelar.CssClass = "btn btn-outline-secondary";
    
13.01.2017 / 20:13