我在 C# 上使用框架 4.0 开发 VSTS 2012。
我默认设置enable = false:
<dx:ASPxTextBox ID="ASPxTextBox_CP_dest" runat="server" Width="60px" TabIndex="30" ClientInstanceName="ASPxTextBox_CP_dest" Enable="false">
<ValidationSettings ErrorDisplayMode="ImageWithTooltip" SetFocusOnError="true">
<RequiredField IsRequired="true" ErrorText="Champ Obligatoire" />
</ValidationSettings>
</dx:ASPxTextBox>
但是当用户点击复选框时:
<dx:ASPxCheckBox
ID="ASPxCheckBox_NewDesti"
runat="server"
ClientInstanceName="ASPxCheckBox_NewDesti"
OnCheckedChanged="Desti_CheckedChanged"
Text="Nouveau destinataire" ForeColor="Green" AutoPostBack="false"
>
</dx:ASPxCheckBox>
然后我将其设置为启用 = true:
protected void Desti_CheckedChanged(object sender, EventArgs e)
{
if (ASPxCheckBox_NewDesti.Checked)
{
ASPxTextBox_CP_dest.Enabled = true;
ASPxTextBox_CP_dest.BackColor = System.Drawing.Color.White;
.....
}
else
{
ASPxTextBox_CP_dest.Enabled = false;
ASPxTextBox_CP_dest.BackColor = System.Drawing.Color.LightGray;
}
但是当我点击保存按钮时:
protected void ASPxButton_save_Click(object sender, EventArgs e)
{
try
{
string FA_Choisi = ASPxTextBox_CP_dest.Text.Substring(0, 2);
我得到了值 ASPxTextBox_CP_dest.Text = empty
回发后我失去了价值。那是因为默认情况下 enable =false 吗?