In aspx code inside the page load event you can store the
IsPostBack
value like:
ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack",
String.Format("var IsPostBack = {0};", Page.IsPostBack.ToString().ToLower()), true);
And then in js code you can check it like
$(document).ready(function () {
alert(IsPostback);
if (!IsPostback) {
$("#Checkboxlist1 :checkbox").attr('disabled', 'disabled');
$("#Checkboxlist1 :checkbox[value='Select All']").removeAttr('disabled');
$("#Checkboxlist1 :checkbox[value='Select All']").prop("checked", true);
}
});
Let me know if you are still facing any issues.
UPDATE:
In aspx:
Add a hidden field like
<asp:HiddenField ID="hfServerValue" runat="server" />
In cs (inside Page_Load):
hfServerValue.Value = Page.IsPostBack.ToString().ToLower();
In js:
$(document).ready(function () {
var IsPostback = $("[id$='hfServerValue']").val();
IsPostback = (IsPostback == 'true');
alert(IsPostback);
if (!IsPostback) {
$("#Checkboxlist1 :checkbox").attr('disabled', 'disabled');
$("#Checkboxlist1 :checkbox[value='Select All']").removeAttr('disabled');
$("#Checkboxlist1 :checkbox[value='Select All']").prop("checked", true);
}
});
Let me know if it works!