PDA

View Full Version : [CLOSED] How do I disable checkbox on page load via code behind?



ermanni.info
Feb 21, 2013, 1:02 AM
Hello!

I'm using the disable feature via checkbox fields as link:

During Page_Load, when the checkbox is unchecked the textfield still enabled. How do I disable the textfield via code behind in Page_Load? (Or if can perform JS Handler component).

Thanks!

Ermanni.

Baidaly
Feb 21, 2013, 4:03 AM
Hello!

Do you mean something like this?




<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Ext.NET Examples</title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Checkbox1.Disabled = true;
TextField1.Disabled = Checkbox1.Disabled;
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Checkbox runat="server" ID="Checkbox1" FieldLabel="Disable">
<Listeners>
<Change Handler="#{TextField1}.setDisabled(newValue);"></Change>
</Listeners>
</ext:Checkbox>

<ext:TextField runat="server" FieldLabel="TextField" ID="TextField1"></ext:TextField>
</form>
</body>
</html>

ermanni.info
Feb 21, 2013, 7:43 AM
Thanks Baidaly,

And apologies for not having informed the link.

Is it even accurate. I was using in the Page_Load method ".Disable()" and was not working. Now with ".Disabled" worked.

Thanks!

Ermanni.

Daniil
Feb 21, 2013, 11:45 AM
Hello,

As a main rule - use properties during initial Page_Load.

The methods such as Disable, Enable, Show, Hide are all designed to be used during an AJAX request (DirectEvent or DirectMethod).