When to use #{}

  1. #1

    When to use #{}

    Hello

    I'm going to ask a question I've been wondering for a long, and is not the answer.

    When you have to use #{} and when not?

    What is the difference between

    Handler="#{store}.reload();"
    Handler="store.reload();"
    Thank you very much.
    Last edited by Daniil; Jun 27, 2012 at 5:30 PM. Reason: Please use [CODE] tags
  2. #2
    Quote Originally Posted by threewonders View Post
    Hello

    I'm going to ask a question I've been wondering for a long, and is not the answer.

    When you have to use #{} and when not?

    What is the difference between

    Handler="#{store}.reload();"
    Handler="store.reload();"

    Thank you very much.
    i have the same question,waiting for the answer
  3. #3
    Hello,

    Wrapping the server-side .ID in #{} will trigger the Ext.NET parser to replace the .ID value with your .ClientID.

    The .ClientID must be unique on the client (browser), so if your Control is placed within an INamingContainer (such as a MasterPage, or UserControl), the server-side .ID will be converted to a unique client-side .id value (.ClientID).

    Summary: Using client-side JavaScript, you must use the .ClientID value to reference Controls. By wrapping in #{}, the Ext.NET Parser will automatically handle this conversion for you. In general you should always wrap your values in #{} if referencing Components by their .ID's using client-side JavaScript.

    If you were just rendering out regular inline JavaScript to alert a server-side value, the code might look like the following:

    var panelID = "<%= this.Panel1.ClientID %>";
    alert(panelID);
    The inline <%= %> will print out the .ClientID value of Panel1. This is similar to #{}.

    You can test the #{} parsing by using an <ext:XScript> Component.

    Example

    <ext:XScript runat="server">
        <script type="text/javascript">
            var panelID = "#{Panel1}";
            alert(panelID);
        </script>
    </ext:XScript>
    
    <ext:Panel ID="Panel1" runat="server" />
    The above code should alert the .ClientID value of Panel1. Just place the above block of code on any Ext.NET enabled Page. You can experiment with how the .ClientID value changes by setting a MasterPage, or adding the above code to UserControl (.ascx).

    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    Thank you very much. I stay clear
  5. #5
    there should be a thanks button here ;)

    Thanks for that nice clearification from my part, too!

Posting Permissions