[CLOSED] HttpException was unhandled by user code: The control with ID 'UC_1752412531_bntOk' not found

  1. #1

    [CLOSED] HttpException was unhandled by user code: The control with ID 'UC_1752412531_bntOk' not found

    Hi!

    I load my usercontrols in my aspx page with ext:UserControlLoader.

    My usercontrol contains buttons Ok and Cancel with directevents.
    When i click in button ok, for exempla, i get an error.

    HttpException was unhandled by user code: The control with ID 'UC_1752412531_bntOk' not found

    seems to me that all controls that have some procedure in codebehind get this error.

    Follow below the example to reproduce this problem.

    Thanks for any help.

    Test4.aspx
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test4.aspx.vb" Inherits="SuperaWeb.test4" %>
    <%@ 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">
    
    <script runat="server">    
        
        Public Shared myRnd As New System.Random
        
        Protected Sub LoadUserControl(sender As Object, e As DirectEventArgs)
    
            Dim ucl As UserControlLoader = New UserControlLoader()
            
            ucl.Path = cmbUC.SelectedItem.Text
            ucl.UserControlID = "UC_" & CStr(myRnd.Next(Integer.MaxValue))
            
            Me.Form.Controls.Add(ucl)
            ucl.Render()
            
            DirectCast(ucl.UserControls(0), SuperaWeb.uc4).Start()
                    
        End Sub
        
    </script> 
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" /> 
        <form id="form1" runat="server">
        <div>
            <ext:ComboBox runat="server" ID="cmbUC">
                <Items>
                    <ext:ListItem Text="UC4.ascx" Value="UC4.ascx" />
                </Items>
                <SelectedItems>
                    <ext:ListItem Text="UC4.ascx" Value="UC4.ascx" />
                </SelectedItems>
            </ext:ComboBox>
            <ext:Button ID="Button1" runat="server" Text="Load UserControl" OnDirectClick="LoadUserControl" />  
        </div>
        </form>
    </body>
    </html>
    UC4.ascx
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="uc4.ascx.vb" Inherits="SuperaWeb.uc4" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        
        Protected Sub Cancel_Click(sender As Object, e As DirectEventArgs)
            Dim mb As Ext.Net.MessageBox = New Ext.Net.MessageBox
            mb.Alert("cancel click", "cancel click")
            mb.Show()
        End Sub
        
        Protected Sub Ok_Click(sender As Object, e As DirectEventArgs)
            Dim mb As Ext.Net.MessageBox = New Ext.Net.MessageBox
            mb.Alert("ok click", "ok click")
            mb.Show()
        End Sub
    
        Protected Sub SearchCep(sender As Object, e As DirectEventArgs)
            Dim mb As Ext.Net.MessageBox = New Ext.Net.MessageBox
            mb.Alert("trigger clicked", "trigger clicked")
            mb.Show()
        End Sub
        
    </script>
    
    <ext:Window 
        ID="wndEmpresasSGE" 
        runat="server"
        Icon="UserAdd"
        Title="Cadastro de Empresas"
        Width="680" 
        Height="530" 
        AutoShow="false" 
        Modal="true" 
        Resizable="false"
        Hidden="true"
        ButtonAlign="Right"
        Layout="FitLayout"
        DefaultButton="button[text=Ok]">
        <Items>
        <ext:Panel ID="pane3" runat="server" BodyStyle="background-color: #f9f9f9" BodyPadding="6" Layout="FitLayout" Border="true" Flex="1"> 
            <TopBar>
                <ext:Toolbar ID="tb3" runat="server">
                    <Items>
                        <ext:Button ID="btnAdd" runat="server" Icon="ApplicationAdd" Text="Add" 
                            ToolTip="Adicionar registro" Disabled="true" />
                        <ext:Button ID="btnEdit" runat="server" Icon="ApplicationEdit" Text="Edit" 
                            ToolTip="Editar registro selecionado" Disabled="true" />
                        <ext:Button ID="btnDelete" runat="server" Icon="ApplicationDelete" 
                            Text="Excluir" ToolTip="Deletar registro(s) selecionados" Disabled="true" />
                        <ext:Button ID="btnFind" runat="server" Icon="Find" Text="Find" 
                            ToolTip="Localizar registro"  Disabled="true" />
                        <ext:ToolbarSeparator ID="ctl133" runat="server" />
                        <ext:Button ID="btnPrint" runat="server" Icon="Printer" Text="Print" 
                            ToolTip="Imprimir registros" Disabled="true" />
                        <ext:Button ID="btnPrintPreview" runat="server" Icon="PrinterGo" 
                            Text="Preview" ToolTip="Visualizar impresso registros" Disabled="true" />
                        <ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server" />
                        <ext:SplitButton ID="btnExport" runat="server" Icon="PageExcel" Text="Export" 
                            ToolTip="Export records to..." Disabled="true">
                            <menu>
                                <ext:Menu runat="server" ID="ctl394">
                                    <Items>
                                        <ext:MenuItem ID="mnuExportToExcel" runat="server" icon="PageExcel" 
                                            Text="Excel" />
                                        <ext:MenuItem ID="mnuExportToPdf" runat="server" icon="PageWhiteAcrobat" 
                                            Text="PDF" />
                                        <ext:MenuItem ID="mnuExportToXml" runat="server" icon="PageCode" Text="Xml" />
                                        <ext:MenuItem ID="mnuExportToText" runat="server" icon="PageWhite" 
                                            Text="Text" />
                                        <ext:MenuItem ID="mnuExportToHtml" runat="server" icon="Html" Text="Html" />
                                    </Items>
                                </ext:Menu>
                            </menu>
                        </ext:SplitButton>
                        <ext:ToolbarFill ID="ctl402" />
                        <ext:ComboBox ID="cmbQueries" runat="server" FieldLabel="Consultas" 
                            LabelWidth="60" Disabled="true">
                        </ext:ComboBox>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <Items>
                <ext:TextField runat="server" ID="txtName" FieldLabel="Nome" Width="300" />
                <ext:TriggerField runat="server" ID="txtCep" FieldLabel="Cep" Width="300">
                    <Triggers>
                        <ext:FieldTrigger Icon="Search"/>
                    </Triggers>
                    <DirectEvents>
                        <TriggerClick OnEvent="SearchCep" />
                    </DirectEvents>
                </ext:TriggerField>
            </Items>
        </ext:Panel>
        </Items>
        <Buttons>
            <ext:Button runat="server" ID="btnOk" Text="Ok" OnDirectClick="Ok_Click" />
            <ext:Button runat="server" ID="btnCancel" Text="Cancel" OnDirectClick="Cancel_Click" />
        </Buttons>
    </ext:Window>
    UC4.ascx Code Behind
    Public Class uc4
        Inherits System.Web.UI.UserControl
    
        Public Sub Start()
            wndEmpresasSGE.Show()
        End Sub
    
    End Class
    Last edited by Daniil; Feb 16, 2012 at 7:03 PM. Reason: [CLOSED]
  2. #2
  3. #3
    Hi Daniil...

    Thanks for your reply... Now I understand better the life-cycle of usercontrols.
    Unfortunately, I could not solve the problem described above.

    So, I changed how I create my Form Details.
    1 - I inserted an ext: Window on main page.
    2 - I am creating my Form Details like asp pages (aspx)
    3 - I'm loading my Form Detail (aspx) with tag Loader of window.
    <ext:Window ID="OrderDetailsWindow" runat="server" Icon="ApplicationFormEdit" Resizable="false" Hidden="true" Modal="true" Constrain="true">
            <Loader AutoLoad="true"  Url="Test6.aspx" Mode="Frame" TriggerEvent="show" ReloadOnEvent="true">
                <LoadMask Msg="Loading customer" ShowMask="true" />
              <Params>
                 <ext:Parameter Name="orderID" Value="" Mode="Value" />
              </Params>
            </Loader>
        </ext:Window>  
        </form>
    4 - In main page, I create a directevent to close de window.
    <DirectMethod()>
        Public Sub CloseWindow(isCancel As Boolean)
            If Not isCancel Then
                'refresh grid
            End If
            wndFormDetail.Hide()
        End Sub
    5 - In my Form Detail, the buttons Ok and Cancel call the directevent CloseWindow of parent page.
        Protected Sub OkClick(sender As Object, e As DirectEventArgs)
            Ext.Net.X.Js.Call("parent.Ext.net.DirectMethods.CloseWindow", False)
        End Sub
    It's working very well and will solve all my problems.
    I just wanted a way that ext: Window resizes itself to fit the content (the Form Detail aspx)
    Is there a way to automatically resize the window as the content?
    If no, I thought about making a directmethod in main page, (window_resize(width, height)) and class this directmethod in page_load of my Form Detail.

    Thanks for any help!
  4. #4
    Ok, thanks for the update.

    Could you please start a new forum thread (since the initial question has been answered)?
  5. #5
    Ok, no problem!

    Thanks for your help.

Similar Threads

  1. Replies: 2
    Last Post: Feb 06, 2012, 10:06 AM
  2. Replies: 2
    Last Post: Nov 02, 2011, 8:07 AM
  3. [CLOSED] Problem loading user control from code behind
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jul 18, 2011, 10:02 PM
  4. how to upload user control dynamicaly on user control
    By archana mahadule in forum 1.x Help
    Replies: 1
    Last Post: Jan 13, 2011, 1:05 PM
  5. Replies: 1
    Last Post: Mar 15, 2008, 12:47 AM

Posting Permissions