I used a partial postback in my ASPX pages. In some of the elements, I specify a css for styling, to mark whether the element is mandatory to fill in. Initially, without putting anything, when I do a partial postback, the styling inside my updatepanel is gone. So I added the code below to add back the lost styling.
function pageLoad(sender, args) {
if (args.get_isPartialLoad()) {
$(".Mandatory").append('  <span style="color:red;">*</span>');
}
}
The problem is that, if the element is outside my update panel, it will have the *
sign duplicated.
Is there any way to resolve this? I.e. how to check if the certain class already have <span style="color:red;">*</span>
so that I do not add the style twice?
You can restrict your selector to only select elements within your updatepanel. For example:
$("#updatepanel .Mandatory").append('  <span style="color:red;">*</span>');