I've hierarchy grid with a runtime controls in the details of each row,
There's a checkbox control in the last column.
and there's a textbox and a validator in the second column
------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------
All these controls are runtime controls built in the "_ItemDataBound" event.
-------------------------------------------------------------------------------------------------------------------------------------
if (e.Item is GridDataItem)
{
if (e.Item.OwnerTableView.Name == "GroupPoints")
{
RequiredFieldValidator rv = new RequiredFieldValidator();
rv.ID = "RequiredFieldValidator4";
rv.ControlToValidate = "txtPointValue";
rv.Display = ValidatorDisplay.Dynamic;
rv.ErrorMessage = "Please select a value";
rv.CssClass = "validator";
rv.ValidationGroup = "CallID";
rv.InitialValue = "";
e.Item.Controls[3].Controls.Add(rv);
TextBox txt = new TextBox();
txt.ID = "txtPointValue";
txt.Width = 100;
e.Item.Controls[3].Controls.Add(txt);
TextBox txtNotes = new TextBox();
txtNotes.ID = "txtNotes";
txtNotes.TextMode = TextBoxMode.MultiLine;
txtNotes.Width = 250;
e.Item.Controls[4].Controls.Add(txtNotes);
CheckBox chkbxNotApplicable = new CheckBox();
chkbxNotApplicable.ID = "chkbxNotApplicable";
chkbxNotApplicable.Text = "Not Applicable";
chkbxNotApplicable.AutoPostBack = true;
chkbxNotApplicable.CheckedChanged += new EventHandler
(chkbxNotApplicable_CheckedChanged);
e.Item.Controls[5].Controls.Add(chkbxNotApplicable);
}
}
--------------------------------------------------------------------------------------------------------------------------------------
The check box has "_CheckedChanged" event that do what I want server side.
---------------------------------------------------------------------------------------------------------------------------------------
protected void chkbxNotApplicable_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkbxNotApplicable = (CheckBox)sender;
GridDataItem item = (GridDataItem)((GridTableCell)chkbxNotApplicable.Parent).Parent;
RequiredFieldValidator validator = ((RequiredFieldValidator)((Control)item["Pointvalue"].Controls[0]));
validator.Enabled = !chkbxNotApplicable.Checked;
}
---------------------------------------------------------------------------------------------------------------------------------------
I want to access the "RequiredFieldValidator4" javascript and disable it if the user check the chkbxNotApplicable checkbox.
I mean, I want to do the same job of the chkbxNotApplicable checkbox using javascript not a server side code.
Is it possible?
Thank you.
There's a checkbox control in the last column.
and there's a textbox and a validator in the second column
------------------------------------------------------------------------------------------------------------------------------------
Label with name | Please type a value |
All these controls are runtime controls built in the "_ItemDataBound" event.
-------------------------------------------------------------------------------------------------------------------------------------
if (e.Item is GridDataItem)
{
if (e.Item.OwnerTableView.Name == "GroupPoints")
{
RequiredFieldValidator rv = new RequiredFieldValidator();
rv.ID = "RequiredFieldValidator4";
rv.ControlToValidate = "txtPointValue";
rv.Display = ValidatorDisplay.Dynamic;
rv.ErrorMessage = "Please select a value";
rv.CssClass = "validator";
rv.ValidationGroup = "CallID";
rv.InitialValue = "";
e.Item.Controls[3].Controls.Add(rv);
TextBox txt = new TextBox();
txt.ID = "txtPointValue";
txt.Width = 100;
e.Item.Controls[3].Controls.Add(txt);
TextBox txtNotes = new TextBox();
txtNotes.ID = "txtNotes";
txtNotes.TextMode = TextBoxMode.MultiLine;
txtNotes.Width = 250;
e.Item.Controls[4].Controls.Add(txtNotes);
CheckBox chkbxNotApplicable = new CheckBox();
chkbxNotApplicable.ID = "chkbxNotApplicable";
chkbxNotApplicable.Text = "Not Applicable";
chkbxNotApplicable.AutoPostBack = true;
chkbxNotApplicable.CheckedChanged += new EventHandler
(chkbxNotApplicable_CheckedChanged);
e.Item.Controls[5].Controls.Add(chkbxNotApplicable);
}
}
--------------------------------------------------------------------------------------------------------------------------------------
The check box has "_CheckedChanged" event that do what I want server side.
---------------------------------------------------------------------------------------------------------------------------------------
protected void chkbxNotApplicable_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkbxNotApplicable = (CheckBox)sender;
GridDataItem item = (GridDataItem)((GridTableCell)chkbxNotApplicable.Parent).Parent;
RequiredFieldValidator validator = ((RequiredFieldValidator)((Control)item["Pointvalue"].Controls[0]));
validator.Enabled = !chkbxNotApplicable.Checked;
}
---------------------------------------------------------------------------------------------------------------------------------------
I want to access the "RequiredFieldValidator4" javascript and disable it if the user check the chkbxNotApplicable checkbox.
I mean, I want to do the same job of the chkbxNotApplicable checkbox using javascript not a server side code.
Is it possible?
Thank you.