[CLOSED] How to use #{...} syntax within javascript function

  1. #1

    [CLOSED] How to use #{...} syntax within javascript function

    I've seen examples where elements were specified with the #{...} syntax. For example:

    <Listeners>
        <Select Handler="foo(#{MyControl});" />
    </Listeners>
    How can I use this syntax within a javascript function? I want to do something like:

    var x = #{MyControl};
  2. #2

    RE: [CLOSED] How to use #{...} syntax within javascript function

    Hi jmcantrell,

    The #{} is a token wrapper/placeholder that we look for an replace with the components .ClientID value.

    If you're configuring some inline JavaScript, you can just directly output the .ClientID value.

    The following sample demonstrates a full scenario.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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>Ext.NET Examples</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <script type="text/javascript">
                var doSomething = function () {
                    var x = <%= this.TextField1.ClientID %>;
    
                    Ext.Msg.notify("Value", x.getValue());
                };
            </script>
    
            <ext:TextField ID="TextField1" runat="server" />
    
            <ext:Button runat="server" Text="Submit" OnClientClick="doSomething()" />
        </form>
    </body>
    </html>
    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] How to use #{...} syntax within javascript function

    Hi,

    Also you can use XScript control
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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>Ext.NET Examples</title>
        
        <ext:XScript runat="server">
            <script type="text/javascript">
                var doSomething = function () {
                    var x = #{TextField1};
                    Ext.Msg.notify("Value", x.getValue());
                };
            </script>
        </ext:XScript>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TextField ID="TextField1" runat="server" />
    
            <ext:Button runat="server" Text="Submit" OnClientClick="doSomething()" />
        </form>
    </body>
    </html>
  4. #4

    RE: [CLOSED] How to use #{...} syntax within javascript function

    Thanks. This works.

Similar Threads

  1. Replies: 1
    Last Post: Jan 17, 2011, 11:18 PM
  2. Replies: 2
    Last Post: Jan 14, 2011, 5:51 PM
  3. [CLOSED] Call Javascript Function
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 21, 2010, 3:58 AM
  4. Replies: 2
    Last Post: Feb 01, 2010, 1:38 PM
  5. [CLOSED] The javascript function in not fire?
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Sep 09, 2009, 10:12 AM

Posting Permissions