Problem with Window and obtaining data from controls + Upload of file

  1. #1

    Problem with Window and obtaining data from controls + Upload of file

    Hello All,

    I have problem with using of Ext.Net.Window in my project. I can display window, add a directmethod to button in window, but when i click on
    this button i enter in direct method function but then i cant get data from any of controls .
    Here is a small example of what i'm doing :

    File: Default.aspx
    =======================================

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
    <%@ 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></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="DM" />
    <div>
    <ext:Viewport ID="MainViewport" runat="server" Layout="border" >
    <Items>
    <ext:Button runat="server" ID="ButtonHandler" Text="Handler" X="120" Y="10" ></ext:Button>
    </Items>
    </ext:Viewport>
    </div>
    </form>
    </body>
    </html>


    File : Default.aspx.cs
    =======================================

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Ext.Net;
    namespace WebApplication2
    {
    public partial class _Default : System.Web.UI.Page
    {
    public Window1 wndRegFile;
    protected void Page_Load(object sender, EventArgs e)
    {

    ButtonHandler.Listeners.Click.Handler = "DM.MainPage.HandlerButtonAdd();";

    wndRegFile = new Window1();
    this.Controls.Add(wndRegFile);
    }

    [DirectMethod]
    public void HandlerButtonAdd()
    {
    wndRegFile.Hidden = false;
    wndRegFile.Render();
    }

    }
    }

    File : Window1.cs
    =======================================

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Ext.Net;
    namespace WebApplication2
    {
    public partial class Window1 : Ext.Net.Window
    {
    public Ext.Net.FormPanel formUpload;
    public Ext.Net.FileUploadField fileUpload;
    public Ext.Net.TextField fileName;
    public Ext.Net.Button btnUpload;

    public Window1()
    {
    this.ID = "id_window_reg_file";
    this.Height = 600;
    this.Width = 800;
    this.Hidden = true;
    CreateControls();
    }

    public void CreateControls()
    {

    this.fileUpload = new Ext.Net.FileUploadField { ID = "id_fldUpload", AllowBlank = false, Width = 200, RenderTo = "formFileUpload", IsFormField = true };
    this.fileName = new Ext.Net.TextField { ID = "id_fldName", Name = "fName", AllowBlank = false, FieldLabel = "Name", X = 50, Y = 50, Width = 200, IsFormField = true };
    this.btnUpload = new Ext.Net.Button
    {
    ID = "id_btnUpload",
    Text = "Upload file",
    Listeners = { Click = { Handler = "Ext.net.DirectMethod.request('Test', {control: 'id_window_reg_file'});" } }
    };

    this.Buttons.Add(this.btnUpload);
    this.formUpload = new Ext.Net.FormPanel
    {
    ID = "id_formFileUpload",
    FileUpload = true,
    RenderFormElement = true,
    LabelAlign = LabelAlign.Top,
    Border = false,
    BodyStyle = "background:transparent;padding:10px;",
    Items =
    {
    this.fileUpload,
    this.fileName
    }
    };

    this.formUpload.RenderTo = "id_window_reg_file";
    this.Items.Add(this.formUpload);
    return;
    }

    [DirectMethod]
    public void Test()
    {
    return;
    }
    }
    }


    Same happens if i didnt call DirectMethod from listeners, but when using DirectEvents like

    this.btnUpload.DirectEvents.Click.Event += this.AddClick_Event;
    this.btnUpload.DirectEvents.Click.EventMask.ShowMa sk = true;
    this.btnUpload.DirectEvents.Click.EventMask.Msg = "Sending data to server...";

    Then, again i'm going in function AddClick_Event but, cant read any data from window , ie
    fileUpload.Text is empty string.

    Can anyone help or provide info where i'm wrong?

    Also, next question will be, how to do file upload from here using web service :)

    Regards,
    Nedelcho
  2. #2
    I find where was a problem

    this.Controls.Add(wndRegFile);

    should be replaced with

    this.Form.Controls.Add(wndRegFile);

    :) Search & Read in Forum help me

Similar Threads

  1. File upload design issue and click problem
    By Nagaraju in forum 1.x Help
    Replies: 0
    Last Post: Jan 17, 2012, 10:08 AM
  2. File Upload Field Problem
    By OSSAGHO in forum 1.x Help
    Replies: 0
    Last Post: Sep 19, 2011, 1:09 PM
  3. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM
  4. [CLOSED] File Upload filed is unable to find in popup window
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 09, 2011, 6:43 AM
  5. File Upload Problem
    By onurbozkurt in forum 1.x Help
    Replies: 3
    Last Post: Feb 16, 2009, 6:47 PM

Tags for this Thread

Posting Permissions