如果AutoPostBack =" false"则只读取asp.net文本框。

时间:2017-11-26 11:37:43

标签: jquery css asp.net readonly

我需要检查TextBox是否有值,然后只读取该字段。我正在使用AutoPostBack="false",所以我猜不会在后端进行。

这是我的代码:

Aspx页面:

<telerik:RadButton runat="server" AutoPostBack="false" CssClass="btnLookup topIngbtnLookup" ID="btnIngredientsLookUp" Image-ImageUrl="~/Images/searchIng.PNG" />

JavaScript的:

$('#txtIngredientsName').keypress(function () {
    if ($(this).val() != '') {
        $(this).addClass('readOnlyFields');
    }
    else {
        $(this).removeClass('readOnlyFields');
    }
});

CSS:

.readOnlyFields {
    pointer-events: none !important;
    background-color: #ccc !important;
}

0 个答案:

没有答案