Dec 22, 2011, 10:56 AM
Setting TextField ReadOnly property to toggle on click of button
Hi,
I am using asp.Net MVC so viewstate is not there, i try to pass the readOnly property of textfield as a parameter but on every click event of the direct event it gives the readonly = false at server side, below is the code that i am working with.
the aspx page is as below
I am using asp.Net MVC so viewstate is not there, i try to pass the readOnly property of textfield as a parameter but on every click event of the direct event it gives the readonly = false at server side, below is the code that i am working with.
the aspx page is as below
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<ext:Window ID="Window_add_PURL" runat="server" Icon="Star" Title="Add a new Prefered url" X="250" Y="100" Height="150" Width="250">
<Items>
<ext:TextField ID="purl_url" FieldLabel="URLTo:" runat="server" Text="http://" >
</ext:TextField>
<ext:Button ID="bt_add_purl" HandleMouseEvents="true" runat="server" Text="Add" Icon="Accept">
<DirectEvents>
<Click OnEvent="add_purl">
<EventMask ShowMask="true" MinDelay="500" Msg="Saving setting..." />
<ExtraParams>
<ext:Parameter Name="url" Mode="Raw" Value="purl_url.getValue()">
</ext:Parameter>
<ext:Parameter Name="readonly" Mode="Raw" Value="purl_url.readOnly">
</ext:Parameter>
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Window>
</body>
<script runat="server">
protected void add_purl(object sender, DirectEventArgs e)
{
string id = purl_url.ClientID;
if (X.IsAjaxRequest)
{
string purl = e.ExtraParams[0].ValueToString();
string s = e.ExtraParams[1].ValueToString();
if (s == "\"false\"")
{
this.purl_url.ReadOnly = true;
purl_url.AddScript("{0}.trigger.un('click', {0}.onTriggerClick, {0});", purl_url.ClientID);
}
else
{
this.purl_url.ReadOnly = false;
purl_url.AddScript("{0}.oldTriggerClick = {0}.onTriggerClick; {0}.onTriggerClick = Ext.emptyFn;", purl_url.ClientID);
}
}
}
</script>
Any kind of help is appreciated. Thanks in advance.