[CLOSED] OnDirectClick on UserControl

  1. #1

    [CLOSED] OnDirectClick on UserControl

    Hi,

    I need to execute a work when I click on Button that is in UserControl loaded dinamically.
    But the code returns error....

    The code:


    Test.aspx

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test.aspx.vb" Inherits="B2B.WEB.Test" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:Button ID="ButtonTestASPX" runat="server" Text="test ASPX" Icon="Accept" OnDirectClick="ButtonTestASPX_Click" />
    
        <ext:Panel ID="PanelControl" runat="server" Width="500" Border="true" />
    </body>
    </html>

    Test.aspx.vb

    Public Class Test
        Inherits System.Web.UI.Page
    
        Private Sub Test_Load(sender As Object, e As EventArgs) Handles Me.Load
            Dim ControlApp As New Ext.Net.UserControlLoader
            ControlApp.Path = "Control.ascx"
            PanelControl.Items.Add(ControlApp)
            PanelControl.UpdateContent()
        End Sub
    
        Protected Sub ButtonTestASPX_Click(sender As Object, e As Ext.Net.DirectEventArgs)
            Ext.Net.X.Msg.Alert("Message", "Hello ASPX").Show()
        End Sub
    
    End Class

    Control.ascx

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Control.ascx.vb" Inherits="B2B.WEB.Control" %>
    
    <ext:Button ID="ButtonTestASCX" runat="server" Text="test ASCX" Icon="Accept" OnDirectClick="ButtonTestASCX_Click" />

    Control.ascx.vb

    Public Class Control
        Inherits System.Web.UI.UserControl
    
        Protected Sub ButtonTestASCX_Click(sender As Object, e As Ext.Net.DirectEventArgs)
            Ext.Net.X.Msg.Alert("Message", "Hello ASCX").Show()
        End Sub
    
    End Class

    When I run the code, appear two button.
    If I click on first button, all OK... and the message will be showed.
    If I click on second button... will display an error and the message will not be shown.

    Can you help me?

    Tnx!
    Last edited by Daniil; Nov 13, 2014 at 4:08 PM. Reason: [CLOSED]
  2. #2
    Hi @Mario,

    Please read this post:
    http://forums.ext.net/showthread.php...l=1#post105183
  3. #3
    OK, problem resolved!

    In Control.ascx file, change the line:

    <ext:Button ID="ButtonTestASCX" runat="server" Text="test ASCX" Icon="Accept" OnDirectClick="ButtonTestASCX_Click" />
    in...

    <ext:Button ID="ButtonTestASCX" runat="server" Text="test ASCX" Icon="Accept" ClientIDMode="Static" OnDirectClick="ButtonTestASCX_Click" />
    :)
  4. #4
    I've just realized (due to your other thread) that you don't create controls on the fly. So, my answer was not correct. There is another problem, I think.

    Please remove:
    PanelControl.UpdateContent()
    It should be called during a DirectEvent only if needed to update the PanelControl's content.
  5. #5
    Tnx Daniil,

    It work very good!

Similar Threads

  1. Replies: 2
    Last Post: Jan 17, 2014, 11:11 AM
  2. Diff between OnClick, OnDirectClick
    By yash.kapoor in forum 2.x Help
    Replies: 2
    Last Post: Jan 12, 2013, 4:34 AM
  3. [CLOSED] MenuItem onDirectClick?
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 05, 2012, 12:01 PM
  4. OnDirectClick
    By cbu in forum 1.x Help
    Replies: 1
    Last Post: Jan 05, 2012, 7:48 PM
  5. Problem with the onDirectClick
    By paddy in forum 1.x Help
    Replies: 5
    Last Post: Jul 26, 2011, 5:09 AM

Tags for this Thread

Posting Permissions