jQuery with ASP.NET WebForms - disabling textboxes

[亡魂溺海] 提交于 2019-12-01 23:47:48

I can't think of a way to augment the css class names that are assigned to controls from the skin file (phoenix is correct, the class names need to be added in the same attribute).

I can think of a few workarounds though:

--> You can wrap all the textboxes you want disabled in a div with a given class:

<div class="disable_textbox"><asp:textbox id="".../></div>

and then disable them by selecting:

$('.disable_textbox input').attr('disabled', true);

--> You can include character strings in the ID of the textboxes you want disabled:

<asp:textbox id="txtDiscountUntil_DisableMe" ... />

and then disable them like so:

$("input[id*='DisableMe']").attr('disabled', true);

--> You can add a custom attribute to your textbox:

txtDiscountUntil.Attributes.Add("disableme", "true");

and then disable them like so:

$("input[disableme='true']").attr('disabled', true);

Your HTML markup is not the correct one.

You can't add two classes like the one in your code.

Two classes can be added like this

<input type="text" class="Class1 Class2" />

and not like

<input type="text" class="Class1" class="Class2" />

Why don't you use hasClass to check whether the element has this class set or not?

I think you have to give this in an OR condition for the two classes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!