Disabling checkboxes on clientside

Hi,

I need to disable checkbox when a client selects a particular value fropm a dropdown in the same row as the checkbox.Can you provide me a piece of code to do this.

Thanks & Regards,

Jai

Hi,
Thanks for considering Aspose.
Well, I think you may try to add a check box validation on some cell and use an event like SubmitCommand to find out the value of the cell having dropdown list and if the value matches your criteria, you may make the cell (having check box validation) read-only or locked.
Here is a sample code:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
GridWeb1.ForceValidation = true;
WebWorksheet worksheet = GridWeb1.WebWorksheets[0];
WebCells cells = worksheet.Cells;
//Apply CheckBox validation.
WebCell cell1, cell2;
cell1 = cells["B2"];
cell1.StringValue = "Check\n the Box";
//cell1.Style.Wrap = true;
cell2 = cells["C2"];
cell2.CreateValidation(ValidationType.CheckBox, true);
// DropDownList.
WebCell cell = cells["E2"];
cell.CreateValidation(ValidationType.DropDownList, true);
cell.Validation.ValueList.Add("Bachelor");
cell.Validation.ValueList.Add("Master");
cell.Validation.ValueList.Add("Doctor");
}
}

private void GridWeb1_SubmitCommand(object sender, System.EventArgs e)
{
if(GridWeb1.WebWorksheets[0].Cells["E2"].StringValue == "Master")
{
GridWeb1.WebWorksheets[0].Cells["C2"].IsReadonly = true;

}
}
Thank you.

Hi ,

Thanks for the code , actually i was looking for a client side script to disable a cell. there is a dropdown box in one of the cell. and after a particular value say A is selected the row sxhould get disabled,similarly if the usr selects B it the row should get enabled again .So i dont think there is anywhere required to write a server side code.Please letme know how to do this as this is urgent.

Thanks & Regards,

Jairam

Hi Jairam,

We will get back to you soon.

Thank you.

Hi,

You may use the OnCellUpdatedClientFunction client side event to enable or disable the check box.

Here is a sample:

in the Page_Load:

if (!IsPostBack)

{

WebCell cell = sheet.Cells["A1"];
Validation v = cell.CreateValidation(ValidationType.CheckBox, true);
cell = sheet.Cells["B1"];
cell.PutValue("A");
v = cell.CreateValidation(ValidationType.DropDownList, true);
v.ValueList.Add("A");
v.ValueList.Add("B");

GridWeb1.OnCellUpdatedClientFunction = "onUpdate";
}

in the aspx file, add the following script: