[CLOSED] CSS style of TextField is not updated properly by DirectMethod

  1. #1

    [CLOSED] CSS style of TextField is not updated properly by DirectMethod

    Hello

    I've noticed strange behaviour of setting additional CSS style via TextField .Cls property.
    In my example, once the "required" style is set, other style ("readonly") cannot be set (there is no change at client)
    In the opposite direction (readonly > required) it works fine.

    What I am doing wrong?

    Please examine.

    P.K.

    test12.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test12.aspx.cs" Inherits="test12" %>
    
    <!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>
    
         <style type="text/css">
            .x-theme-slate  .readonly { background: #FFFFFF; cursor: default; color:Gray}    
            .x-theme-slate  .required { background: #FFFFCC; cursor: default; color:Black}
         </style>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>
    test12.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Web;
    using Ext.Net;
    
    public partial class test12 : System.Web.UI.Page
    {
      private TextField text1;
    
      protected void Page_Load(object sender, EventArgs e)
      {
    
        ResourceManager res_man = new ResourceManager();
        res_man.DirectMethodNamespace = "dm";
        res_man.IDMode = IDMode.Explicit; // explicit client IDs
        res_man.Theme = Ext.Net.Theme.Slate;
    
        res_man.DisableViewState = true;
        res_man.AjaxViewStateMode = Ext.Net.ViewStateMode.Disabled;
    
        var button1 = new Button("Set readonly");
        button1.ID = "button1";
        button1.Listeners.Click.Handler = "dm.set_style('readonly');";
    
        var button2 = new Button("Set required");
        button2.ID = "button2";
        button2.Listeners.Click.Handler = "dm.set_style('required');";
    
        text1 = new TextField();
        text1.ID = "text1";
        text1.Value = "text1"; // OK
    
        form1.Controls.Add(res_man);
        form1.Controls.Add(text1);
        form1.Controls.Add(button1);
        form1.Controls.Add(button2);
         
      }
    
      [DirectMethod]
      public void set_style(string style)
      {
        text1.Cls = style;
      }
    
    }
    Last edited by geoffrey.mcgill; Sep 28, 2012 at 9:41 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You should remove a previously added class using the RemoveClass method.
  3. #3
    Now it works fine, thanks.
    I need to get used to CSS.

    Regards,
    P.K.

Similar Threads

  1. Replies: 5
    Last Post: Jun 22, 2012, 2:47 PM
  2. [CLOSED] Set style for TextField
    By Digital.Dynamics in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 11, 2012, 2:34 PM
  3. [CLOSED] IE/Firefox Textfield padding style
    By softmachine2011 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 04, 2012, 3:52 PM
  4. Replies: 2
    Last Post: Jan 16, 2012, 10:34 AM
  5. Replies: 3
    Last Post: May 20, 2011, 8:55 PM

Posting Permissions