[CLOSED] How to name ExtraParams dynamically in markup?

  1. #1

    [CLOSED] How to name ExtraParams dynamically in markup?

    Hi,

    Please suggest how to correctly name ExtraParams in the markup dynamically. Here's the code sample I'm trying to work with:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        const string Const1 = "Constant1";
        const string Const2 = "Constant2";
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest) return;
        }
    
        protected void ButtonSave_Click(object sender, DirectEventArgs e)
        {
            var param1 = e.ExtraParams[Const1];
            var param2 = e.ExtraParams[Const2];
        }
    </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 Examples</title>
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder2" runat="server" Mode="Style" />
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Panel ID="Panel1" runat="server" Width="800" Height="600">
            <Items>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <Center>
                        <ext:FormPanel ID="FormPanel1" runat="server" Title="Form Panel" Padding="5" ButtonAlign="Right"
                            TrackResetOnLoad="true">
                            <Items>
                                <ext:TextField ID="CompanyField" DataIndex="company" runat="server" FieldLabel="Company"
                                    AnchorHorizontal="95%" />
                                <ext:TextField ID="PriceField" DataIndex="price" runat="server" FieldLabel="Price"
                                    AnchorHorizontal="95%" />
                                <ext:TextField ID="ChangeField" DataIndex="change" runat="server" FieldLabel="Change"
                                    AnchorHorizontal="95%" />
                                <ext:TextField ID="PctChangeField" DataIndex="pctChange" runat="server" FieldLabel="Change (%)"
                                    AnchorHorizontal="95%" />
                                <ext:DateField ID="lastChange" runat="server" FieldLabel="Last Updated" AnchorHorizontal="95%" />
                            </Items>
                            <Buttons>
                                <ext:Button runat="server" ID="ButtonSave" Text="Save">
                                    <DirectEvents>
                                        <Click OnEvent="ButtonSave_Click" Success="Ext.Msg.alert('Prompt', 'Success!');">
                                            <EventMask ShowMask="true" />
                                            <ExtraParams>
                                                <ext:Parameter Name="<%# Const1 %>" Value="1" Mode="Raw" />
                                                <ext:Parameter Name="<%# Const2 %>" Value="2" Mode="Raw" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Buttons>
                        </ext:FormPanel>
                    </Center>
                </ext:BorderLayout>
            </Items>
        </ext:Panel>
        </form>
    </body>
    </html>
    Last edited by geoffrey.mcgill; Sep 10, 2013 at 3:57 AM. Reason: [CLOSED]
  2. #2
    You just need to add .AutoDataBind="true" to each of those <ext:Parameter> configs.

    Example

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        const string Const1 = "Constant1";
        const string Const2 = "Constant2";
         
        protected void ButtonSave_Click(object sender, DirectEventArgs e)
        {
            var param1 = e.ExtraParams[Const1];
            var param2 = e.ExtraParams[Const2];
    
            X.Msg.Notify("param1", param1).Show();
            X.Msg.Notify("param2", param2).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
    </head>
    <body>
        <form runat="server">
        
        <ext:ResourceManager runat="server" />
        
        <ext:Button runat="server" Text="Save">
            <DirectEvents>
                <Click OnEvent="ButtonSave_Click">
                    <ExtraParams>
                        <ext:Parameter Name="<%# Const1 %>" Value="1" Mode="Raw" AutoDataBind="true" />
                        <ext:Parameter Name="<%# Const2 %>" Value="2" Mode="Raw" AutoDataBind="true" />
                    </ExtraParams>
                </Click>
            </DirectEvents>
        </ext:Button>
        </form>
    </body>
    </html>
    As well, in future posts, please ensure you reduce your code samples down to the minimum required to reproduce the problem.
    Geoffrey McGill
    Founder
  3. #3
    Thanks much for the quick response Geoffrey, it works! Please mark this question as resolved.

Similar Threads

  1. Replies: 6
    Last Post: Aug 01, 2011, 4:53 PM
  2. ASP.NET Markup Error
    By Hiverli in forum 1.x Help
    Replies: 1
    Last Post: Nov 05, 2010, 5:55 PM
  3. code behind vs markup
    By ttbsoftware in forum 1.x Help
    Replies: 2
    Last Post: Aug 11, 2010, 4:51 PM
  4. Replies: 2
    Last Post: Nov 22, 2009, 8:34 AM
  5. Why use Markup instead of Codebehind?
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Apr 21, 2009, 7:51 PM

Tags for this Thread

Posting Permissions