[CLOSED] Get Dynamic TextField Text...

  1. #1

    [CLOSED] Get Dynamic TextField Text...

    Hi,

    I dynamic built TextFile,Image in Panel,
    When save button click, I have to get TextField text to my db
    how can i get the TextFile text ???

    pageload

    for (int i = 0; i < mytmp.Rows.Count; i++)
                            {
                                Ext.Net.Panel mypanel = new Ext.Net.Panel();
                                mypanel.Title = mytmp.Rows[i]["col1"].ToString();
                                Ext.Net.Image myimg = new Ext.Net.Image();
                                myimg.ImageUrl =  mytmp.Rows[i]["col2"].ToString() + ".jpg";
                                mysignlist.Add(mytmp.Rows[i]["col1"].ToString() + " " + mytmp.Rows[0]["col2"].ToString());                            
                                myimg.Hidden = false;
                                myimg.Width = 80;
                                myimg.Height = 80;
                                mypanel.Add(myimg);
                                Ext.Net.TextField myfield = new Ext.Net.TextField();
                                myfield.Text = mytmp.Rows[0]["col2"].ToString();
                                myfield.Hidden = true;
                                mypanel.Add(myfield);
                                Panel17.Add(mypanel);
                            }
    thanks for your help.
    Last edited by geoffrey.mcgill; Apr 24, 2012 at 4:35 AM. Reason: please use [CODE] tags, [CLOSED]
  2. #2
    Hi,

    Please clarify where do you create that TextField? During DirectEvent or Page_Load? Do you recreate that TextField during each DirectEvent?
  3. #3
    Another option that might be helpful in this scenario would be to just loop through all the submitted form Name+Value pairs.

    I don't think re-creating the controls upon each request is practical for this type of scenario.

    this.Request.Form
    Another option is using X.GetCmp<TextField>("ID_HERE"), which will attempt to create a proxy instance of the Field, based upon the values sumitted in the Request.

    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    I create TextField at Page_Load

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["status"] == "INS")
                {
                       DataTable mytmp;
    
                        if (mytmp.Rows.Count > 0)
                        {
                            for (int i = 0; i < mytmp.Rows.Count; i++)
                            {
                                Ext.Net.Panel mypanel = new Ext.Net.Panel();
                                mypanel.Title = mytmp.Rows[i]["col1"].ToString();
                                Ext.Net.Image myimg = new Ext.Net.Image();
                                myimg.ImageUrl =  mytmp.Rows[i]["col2"].ToString() + ".jpg";
                                mysignlist.Add(mytmp.Rows[i]["col3"].ToString() + " " + mytmp.Rows[0]["col4"].ToString());                            
                                myimg.Hidden = false;
                                myimg.Width = 80;
                                myimg.Height = 80;
                                mypanel.Add(myimg);
                                Ext.Net.TextField myfield = new Ext.Net.TextField();
                                myfield.Text = mytmp.Rows[0]["col5"].ToString();
                                myfield.Hidden = true;
                                mypanel.Add(myfield);
                                Panel17.Add(mypanel);
                            }
                            
                        }
                    }
                }
    I don't recreate that TextField during DirectEvent


    Quote Originally Posted by Daniil View Post
    Hi,

    Please clarify where do you create that TextField? During DirectEvent or Page_Load? Do you recreate that TextField during each DirectEvent?
    Last edited by geoffrey.mcgill; Apr 23, 2012 at 1:42 AM. Reason: please use [CODE] tags
  5. #5
    My recommendations above are probably the best way to approach this problem.
    Geoffrey McGill
    Founder
  6. #6
    I still can't get text
    I do sothing wrong????
    please help me, thank you
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["status"] == "INS")
                {
                                  
                        DataTable mytmp;
                        if (mytmp.Rows.Count > 0)
                        {
                            for (int i = 0; i < mytmp.Rows.Count; i++)
                            {
                                Ext.Net.Panel mypanel = new Ext.Net.Panel();
                                mypanel.Title = mytmp.Rows[i]["col1"].ToString();
                                Ext.Net.Image myimg = new Ext.Net.Image();
                                myimg.ImageUrl = mytmp.Rows[i]["col1"].ToString() + ".jpg";
                                mysignlist.Add(mytmp.Rows[i]["col1"].ToString() + " " + mytmp.Rows[0]["col1"].ToString());                            
                                myimg.Hidden = false;
                                myimg.Width = 80;
                                myimg.Height = 80;
                                mypanel.Add(myimg);
                                Ext.Net.TextField myfield = new Ext.Net.TextField();
                                myfield.ID = "meet4";
                                myfield.Text = mytmp.Rows[0]["col1"].ToString();
                                //myfield.Hidden = true;
                                mypanel.Add(myfield);
                                Panel17.Add(mypanel);        
                    
                            }               
                        }
                    }
                }
     protected void Save_Data(object sender, DirectEventArgs e)
        {
            TextField MyF = X.GetCmp<TextField>("meet4");
            mylist.Add(MyF.Text);
          
         }
         <ext:Panel ID="Panel9" runat="server"  Layout="Absolute" Region="Center" Title="" BodyPadding="5"  Height ="400">
                        <TopBar>
                            <ext:Toolbar ID="Toolbar1" runat="server">
                                <Items>
                                    <ext:Button ID="bt_save" runat="server" Text="save" Icon="Disk">
                                        <DirectEvents>
                                           <Click OnEvent="Save_Data">
                                              <EventMask ShowMask="True" Msg="wait..." MinDelay="500" />
                                           </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                    
                                    <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
    
      </ext:Panel>
    Quote Originally Posted by geoffrey.mcgill View Post
    My recommendations above are probably the best way to approach this problem.
  7. #7
    Please wrap your code samples in [CODE] tags. The following posts detail several tips for posting in the forums, see

    http://forums.ext.net/showthread.php...ing-New-Topics

    http://forums.ext.net/showthread.php...ation-Required
    Geoffrey McGill
    Founder
  8. #8
    Hi,

    Based upon the code sample you have posted, your code does appear correct. I cannot see any obvious problems.

    I created the following sample which demonstrates the full scenario of building dynamic Fields during a DirectEvent, then getting those dynamic values during a future DirectEvent.

    Example

    <%@ Page Language="C#" %> 
    <%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>
    
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            this.FormPanel1.Items.AddRange(new[] { 
                new TextField { ID = "TextField1", FieldLabel = "Item 1" },
                new TextField { ID = "TextField2", FieldLabel = "Item 2" },
                new TextField { ID = "TextField3", FieldLabel = "Item 3" },
            });
    
    
            this.FormPanel1.Update();
        }
    
    
        protected void Button2_Click(object sender, DirectEventArgs e)
        {
            var tpl = "Item 1 : {0}<br />Item 2 : {1}<br />Item 3 : {2}";
            
            var item1 = X.GetCmp<TextField>("TextField1").Text;
            var item2 = X.GetCmp<TextField>("TextField2").Text;
            var item3 = X.GetCmp<TextField>("TextField3").Text;
            
            X.Msg.Notify("Values", string.Format(tpl, item1, item2, item3)).Show();
        }
    </script>
    
    
    <html>
    <head>
        <title>Ext.NET Example</title>
    </head>
    <body>
    <form runat="server">
        <ext:ResourceManager runat="server" />
         
        <ext:Button runat="server" Text="Create Fields" OnDirectClick="Button1_Click" />
        <ext:Button runat="server" Text="Get Values" OnDirectClick="Button2_Click" />
    
    
        <ext:FormPanel 
            ID="FormPanel1" 
            runat="server" 
            Title="Example" 
            DefaultAnchor="100%"
            Padding="5" 
            Height="215"
            Width="350"
            />
    </form>
    </body>
    </html>
    Geoffrey McGill
    Founder
  9. #9
    It's worked..thank you

Similar Threads

  1. [CLOSED] TextField.Text is empty in OnDirectClick
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 08, 2012, 1:05 PM
  2. [CLOSED] how to display text or value in textfield using javascript
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 19, 2011, 11:18 AM
  3. ext:TextField text wrap please help
    By gopikrishna in forum 1.x Help
    Replies: 0
    Last Post: Feb 14, 2011, 7:50 AM
  4. [CLOSED] Cannot set the text in a TextField
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 12, 2010, 4:34 PM
  5. TextField text disappearing
    By EzaBlade in forum 1.x Help
    Replies: 8
    Last Post: Apr 24, 2009, 7:46 AM

Posting Permissions