Dec 19, 2011, 12:37 PM
Setting the TextField ReadOnly property to toggle on click of Button
I want a toggle button to set the textfield readonly property to set to false and true on click of button at server side.
But the TextField1.ReadOnly property always shows false on server side.
The below code doesn't work.
But the TextField1.ReadOnly property always shows false on server side.
The below code doesn't work.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReadOnlyPropertyTestForm1.aspx.cs"
Inherits="CooliteTestApplication1.ReadOnlyPropertyTestForm1" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void SetReadOnlyFalse(object sender, DirectEventArgs e)
{
this.TextField1.Text = "I'm editable";
if (this.TextField1.ReadOnly == false)
{
this.TextField1.ReadOnly = true;
}
else
{
this.TextField1.ReadOnly = false;
}
if (this.TextField1.Disabled == true)
{
this.TextField1.Disabled = false;
}
else
{
this.TextField1.Disabled = true;
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:resourcemanager runat="server" />
<div>
<ext:textfield id="TextField1" runat="server" text="I'm read only" />
<ext:button runat="server" text="Set up ReadOnly to false" ondirectclick="SetReadOnlyFalse" />
</div>
</form>
</body>
</html>
Any help is highly appreciated. thx in advance
Last edited by geoffrey.mcgill; Dec 20, 2011 at 2:30 AM.
Reason: please use [CODE] tags