[CLOSED] Dynamically added Ext.Net.Image not converting '~/'

  1. #1

    [CLOSED] Dynamically added Ext.Net.Image not converting '~/'

    Hello!

    When I have an Ext.Net.Image with ImageUrl='~/' it converts alright. When I add it dynamically, it doesnt. It just leaves the '~/' in the url.

    Bellow in a sample to reproduce.

    Thanks.

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        private void Button1(object sender, DirectEventArgs e)
        {
            new Ext.Net.Image { ImageUrl = "~/1234.jpg" }.AddTo(Container1);
        }
    
    </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 id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Button runat="server" Text="Test">
            <DirectEvents>
                <Click OnEvent="Button1" />
            </DirectEvents>
        </ext:Button>
        <ext:Container ID="Container1" runat="server">
            <Items>
                <ext:Image ImageUrl="~/123.jpg" runat="server" />
            </Items>
        </ext:Container>
        </form>
    </body>
    </html>
    Last edited by Daniil; Nov 02, 2011 at 4:11 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Yes, because the .AddTo() method doesn't add a control to any controls collection.

    Please use:
    Ext.Net.Image image = new Ext.Net.Image { ImageUrl = "~/1234.jpg" };
    this.Container1.Items.Add(image);
    image.Render();
    instead of
    new Ext.Net.Image { ImageUrl = "~/1234.jpg" }.AddTo(Container1);

Similar Threads

  1. Iteration on dynamically added controls
    By kutlu in forum 1.x Help
    Replies: 1
    Last Post: Jan 02, 2011, 7:14 PM
  2. [CLOSED] [1.0] removing dynamically added controls
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 29, 2010, 7:49 PM
  3. dynamically added image and getOriginalSize()
    By bakardi in forum 1.x Help
    Replies: 1
    Last Post: Nov 15, 2010, 4:38 PM
  4. [CLOSED] Get script for a dynamically added control
    By jchau in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 30, 2010, 7:23 PM
  5. Populate value of dynamically added control
    By danielg in forum 1.x Help
    Replies: 0
    Last Post: Feb 09, 2009, 12:53 PM

Posting Permissions