[CLOSED] Update label Icon over AjaxMethod

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Update label Icon over AjaxMethod

    Hello,

    When I'm updating a label via an AjaxMethod, the text and so on get's updated fine, but when I do:

    
    
    this.labelOrderType.Icon = Icon.Lorry;
    The icon gets blank. It provides the space for the Icon, but it doesn't show it.

    Any idea,

    Kind regards,

    Reno
  2. #2

    RE: [CLOSED] Update label Icon over AjaxMethod

    By the way, is it not possible to update a fieldlabel of a datefield via AjaxMethod?

    I have this:

    
    
    <ext:DateField ID="OrderDeliveryDateField" runat="server" ShowToday="true"></ext:DateField>
    In the aspx.cs file I have this:

    
    
    this.OrderDeliveryDateField.FieldLabel = "Deliverydate";
    But nothing appears...
  3. #3

    RE: [CLOSED] Update label Icon over AjaxMethod

    Update:

    I've created an intermediate solution:

    I've added a second label and gave the first label my first icon and the second label the second icon. The second label is set to hidden and NOT used.

    Now it works:

    <ext:Label ID="labelOrderType" runat="server" Icon="Lorry" />
    <ext:Label ID="label1" runat="server" Icon="Basket" Hidden="true" />
    In the aspx.cs file I switch the icon of labelOrderType between Lorry and Basket.

    I think you only load those icons which are used from the start.

    Thanks, now yet an answer for the update of the fieldlabel of a datefield.

    Thanks!

    Reno
  4. #4

    RE: [CLOSED] Update label Icon over AjaxMethod

    ...now yet an answer for the update of the fieldlabel of a datefield.
    Hi Reno,

    I've added the ability to update the FieldLabel property during an AjaxEvent/AjaxMethod request.

    The following code sample demonstrates a full scenario.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Button1_Click(object sender, AjaxEventArgs e)
        {
            string text = this.TextField1.Text;
    
            if (!string.IsNullOrEmpty(text))
            {
                this.TextField1.FieldLabel = text;
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager runat="server" />
            
            <ext:Panel 
                ID="Panel1"
                runat="server" 
                Title="Title"
                AutoHeight="true"
                Width="500"
                BodyStyle="padding:10px;">
                <Body>
                    <ext:FormLayout runat="server" LabelAlign="Top">
                        <Anchors>
                            <ext:Anchor Horizontal="100%">
                                <ext:TextField 
                                    ID="TextField1" 
                                    runat="server" 
                                    FieldLabel="Original FieldLabel" 
                                    EmptyText="New Label Text Here..."
                                    />
                            </ext:Anchor>
                        </Anchors>
                    </ext:FormLayout>
                </Body>
                <Buttons>
                    <ext:Button runat="server" Text="Update">
                        <AjaxEvents>
                            <Click OnEvent="Button1_Click" />
                        </AjaxEvents>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </form>
    </body>
    </html>
    Please SVN update and re-test.

    Hope this helps.

    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] Update label Icon over AjaxMethod

    Hello,

    It still doesn't work, it gives me the following error (now I get an error, before the SVN update I didn't):
    Microsoft JScript compilation error: Expected ';'
    on line:
    var task=new Ext.util.DelayedTask(function(o,result,response){if(result.script&amp;&amp;result.script.length>0){eval(result.script);}
    result.script contains this:
    Coolite.Ext.setValues([[OrderFirstName,"Sven"],[OrderLastName,"De Leeuw"],[OrderCompanyName,""],[OrderVAT,""],
    [OrderStreet,"Nieuwe Kaai"],[OrderStreetNumber,"32A "],[OrderZipCode,"1760"],[OrderCity,"Roosdaal"],
    [OrderEmail,"svendeleeuw@yahoo.com"],[OrderPhone,"0477402152"],[OrderCellPhone,""],[OrderDeliveryFirstName,"Sven"],
    [OrderDeliveryLastName,"De Leeuw"],[OrderDeliveryStreet,"Nieuwe Kaai"],[OrderDeliveryStreetNumber,"32A 
    "],[OrderDeliveryZipCode,"1760"],[OrderDeliveryCity,"Roosdaal"],[OrderDeliveryCompanyName,""],[OrderOrderDate,"3/6/2009"],
    [OrderPaymentDate,"3/6/2009"],[OrderDeliveryDateField,new Date(2009,5,6,13,44,47)],[OrderPrice,"399"],[OrderTotal,"399"],
    [OrderPayID,"147156226"],[OrderPaymentMethod,"CreditCard"],[OrderPaymentBrand,"VISA"],[OrderBankAccountNumber,""],
    [OrderMethod,"Delivery"],[OrderChargesOrDiscount,"+ 0"],[OrderID,"274"]]);labelOrderType.setText("<strong>Delivery</strong>",false);labelOrderType.setIconClass("icon-lorry");
    OrderChargesOrDiscount.el.parent().parent().child("label").update("Charges")OrderDeliveryDateField.el.parent().parent().child("label").update("Deliverydate")OrderStatusID.setValue("3");
    windowEdit.setTitle("Edit [274]");
    windowEdit.show();
    I have the following fields:
    <ext:Anchor Horizontal="95%">
        <ext:TextField 
            ID="OrderChargesOrDiscount" 
            runat="server" 
            FieldLabel="Charges/Discount" 
            ReadOnly="true"
        />
    </ext:Anchor>
    <ext:Anchor Horizontal="95%">
        <ext:DateField 
            ID="OrderDeliveryDateField" 
            runat="server" 
            ShowToday="true" 
            FieldLabel="Pickup/Delivery Date"
        />
    </ext:Anchor>
    In my AjaxMethod I have:
    this.OrderChargesOrDiscount.FieldLabel = "Charges";
    this.OrderDeliveryDateField.FieldLabel = "Deliverydate";
    Now the strange part is that when I remove in my AjaxMethod the second line (the one that changes the datefield label), it works fine.

    Oh, I see the error.
    After the update function in your generated script you don't have a ; closure.
    Therefore it works when I only use one update of a fieldlabel, but crashes it on subsequent updates.

    Could you change this please?

    Thanks,

    Reno
  6. #6

    RE: [CLOSED] Update label Icon over AjaxMethod

    ok, Found it:

    In Component.cs in the Ext Folder:
                this.AddScript("{0}.el.parent().parent().child(\"label\").update(\"{1}\")", this.ClientID, text);
    should be:
    
                this.AddScript("{0}.el.parent().parent().child(\"label\").update(\"{1}\");", this.ClientID, text);

    Thanks for changing it in SVN

    Kind regards,

    Reno



  7. #7

    RE: [CLOSED] Update label Icon over AjaxMethod

    It still doesn't work...

    Now I get:
    Microsoft JScript runtime error: 'OrderChargesOrDiscount.el' is null or not an object

    Is it maybe because this field is located on a tab which isn't visible yet at the moment of opening my form?

    If I continue I receive the next error:
    Microsoft JScript runtime error: 'OrderDeliveryDateField.el.parent().parent().child (...)' is null or not an object

    And that field IS shown directly on my form (not in a tab that is).

    So in any case it doesn't really work:
    Quick question: Did you test it before putting it into SVN? ;-)

    Kind regards,

    Reno
  8. #8

    RE: [CLOSED] Update label Icon over AjaxMethod

    Hi Reno,

    I've committed a couple revisions to the SetFieldLabel Method.

    As well, set DeferredRender="false" on your TabPanel.

    Geoffrey McGill
    Founder
  9. #9

    RE: [CLOSED] Update label Icon over AjaxMethod

    Hello Geoffrey,

    It works now for the first field (textfield), but still not for the datefield...

    What else could be wrong?

    Maybe el.parent().parent().child("label") is different in case of Datefield, just a guess

    Kind regards,

    Reno
  10. #10

    RE: [CLOSED] Update label Icon over AjaxMethod

    Yep, checked it out and in case of DateField you have to give it three times the parent.

    So in that case it should be something like : el.parent().parent().parent().child("label")
    I guess ;-)
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: Jan 08, 2010, 2:47 AM
  2. Update asp.net Repeater with AjaxMethod
    By FreddieBoo in forum 1.x Help
    Replies: 3
    Last Post: Aug 13, 2009, 7:21 AM
  3. How do I update an image url via an AjaxMethod?
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Apr 28, 2009, 11:12 AM
  4. [CLOSED] GridPanel + Icon and/or Label Icon
    By state in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 28, 2009, 2:03 AM

Posting Permissions