0

i am using jquery for enabling and disabling a button

$(function () {
$('.CSSCheck').click(function () {
    if ($("[id$='Chkbox']:checked").length > 0) {
        $("#<%=Button1.ClientID %>").removeAttr('disabled');
    }
    else {
        $("#<%=Button1.ClientID %>").attr('disabled', 'disabled');

    }
});
});

on code behind i am adding a css to datalist image button on Select_Command

DataListItemCollection xxx = datalist1.Items;  
int index = id;
int count = 0;     
foreach (DataListItem x in xxx )
{
   if (count == index)
        {
          (x.FindControl("btn1") as ImageButton).BorderColor = System.Drawing.Color.Blue;
          (x.FindControl("btn1") as ImageButton).BorderWidth = 1;
        }
}

how to remove this css using the same jquery?

2
  • you mean remove against all button in the List or just specific one? Commented Feb 28, 2012 at 10:51
  • removing from the selected one, because my code behind css is getting applied in a particular image button(which is selected), how could i make my blue color to white through using my jquery Commented Feb 28, 2012 at 10:54

1 Answer 1

3

This should work

$("#<%=Button1.ClientID %>").css('border', '');

It is recommended however to use classes

$("#<%=Button1.ClientID %>").removeClass('myborder');

in code-behind:

(x.FindControl("btn1") as ImageButton).CssClass = "myborder";

Style definition:

.myborder { border: 1px solid Blue; }
Sign up to request clarification or add additional context in comments.

2 Comments

Button1 is different (its out side of datalist), and btn1 is different(its inside the datalist)
You can change jQuery selector to search for buttons with class assigned from code-behind: $(".myborder").removeClass('myborder');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.