[CLOSED] [1.0] DirectEvent Issues

  1. #1

    [CLOSED] [1.0] DirectEvent Issues

    Since I have these issues alot when I update from SVN I'll let you test it with a grain of salt. However I did rollback to the revision before and it's working so I'm thinking it might be a bug.

    Since upgrading to Revision 3371 from SVN.

    ISSUE: Directevents & Comboboxes
    
    ERROR:
    Inner Exception Type :System.NullReferenceException
    Current User :LJANKOWSKI
    Inner Exception :Object reference not set to an instance of an object.
    Inner Source :Ext.Net.ComboBox
    Inner Stack Trace : at Ext.Net.ComboBox.LoadPostData(String postDataKey, NameValueCollection postCollection) at Ext.Net.Field.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    here is my code

    
     <ext:Button ID="Button4" runat="server" Text="Save" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="ContactAdd">
                        </Click>
                    </DirectEvents>
                </ext:Button>
    codebehind
    Public Sub ContactAdd(ByVal sender As Object, ByVal e As DirectEventArgs)
    
            Dim OrclCmd As New OracleCommand("XXDBI_AM_VALIDATION.VALIDATE_ADDRESS", ReturnOracleConnection)
            OrclCmd.CommandType = CommandType.StoredProcedure
    
            Dim returnval As String = Nothing
            OrclCmd.BindByName = True
            OrclCmd.Parameters.Add("P_CITY_NAME", OracleDbType.Varchar2, tfCity.SelectedItem.Text.ToString, ParameterDirection.Input)
            OrclCmd.Parameters.Add("P_COUNTY_NAME", OracleDbType.Varchar2, tfCounties.SelectedItem.Text.ToString, ParameterDirection.Input)
            OrclCmd.Parameters.Add("P_STATE_NAME", OracleDbType.Varchar2, tfState.SelectedItem.Text.ToString, ParameterDirection.Input)
            OrclCmd.Parameters.Add("P_POSTAL_CODE", OracleDbType.Varchar2, tfPostal.Text.ToString, ParameterDirection.Input)
            OrclCmd.Parameters.Add("VALID", OracleDbType.Varchar2, 1).Direction = ParameterDirection.Output
            OrclCmd.Connection.Open()
            OrclCmd.ExecuteScalar()
    
            returnval = OrclCmd.Parameters("VALID").Value.ToString
    
            If (returnval = "N") Then
                Ext.Net.ExtNet.Msg.Confirm("Warning Invalid Address", "The address you have entered does not appear to be a valid address. Are you sure you want to use this address?", "if (buttonId == 'yes') { Ext.net.DirectMethods.SaveContactData(); }").Show()
            Else
                SaveContactData()
            End If
            OrclCmd.Connection.Close()
            OrclCmd.Dispose()
    
        End Sub
    Last edited by geoffrey.mcgill; Dec 16, 2010 at 6:28 PM. Reason: [CLOSED], please use [CODE] tags
  2. #2
    Hi,

    Can you post a simplified .aspx code sample which demonstrates how to reproduce this exception locally?
    Geoffrey McGill
    Founder
  3. #3
    Ok I did a little digging and it only seems to be an issue when I click one of the drop down boxes that use a generic handler to return the results and then attempt to click the directevent called ContactAdd. If I don't click on a combo box, and attempt the directevent, it works as expected. If I click the combo and load the data it works fine but then it seems it has issues finding it the control called tfCity, as if it's lost?

    Here is the example, the window that loads the form, using the example of the of a searching combo I have modified it a little bit.
    I removed some of the other combo boxes to make it easier to understand. If needed I can try to make it simpler, I'm away from the office now so I don't have access to my full system till I get in tomorrow.

    Again using the example https://examples1.ext.net/#/Form/Com...Custom_Search/


    <ext:Window runat="server" ID="AddContact" Height="465" Width="500" Title="Contact Maintenance"
            Resizable="false" Maximizable="false" Minimizable="false" Hidden="true" InitCenter="true"
            Modal="true" Border="false" Layout="Form">
            <Items>
                <ext:FormPanel runat="server" ID="FrmContact" PaddingSummary="5">
                    <Items>
                        <ext:TextField ID="tfName" runat="server" FieldLabel="Name" AllowBlank="false" AnchorHorizontal="100%" />
                        <ext:TextField ID="tfTitle" runat="server" FieldLabel="Title" AllowBlank="false"
                            AnchorHorizontal="100%" />
                        <ext:TextField ID="tfDepartment" runat="server" FieldLabel="Department" AllowBlank="false"
                            AnchorHorizontal="100%" />
                        <ext:TextField ID="tfEmail" runat="server" Vtype="email" FieldLabel="Email" AnchorHorizontal="100%" />
                        <ext:TextField ID="tfAddress1" runat="server" FieldLabel="Address1" AnchorHorizontal="100%" />
                        <ext:TextField ID="tfAddress2" runat="server" FieldLabel="Address2" AnchorHorizontal="100%" />
                        <ext:ComboBox runat="server" ID="tfCity" Editable="true" TypeAhead="false" FieldLabel="City"
                            AnchorHorizontal="70%" DisplayField="Name" LoadingText="Searching..." ValueField="Name"
                            ForceSelection="true" PageSize="10" HideTrigger="false" MinChars="1">
                            <Store>
                                <ext:Store runat="server" AutoLoad="false">
                                    <Proxy>
                                        <ext:HttpProxy Method="POST" Url="Cities.ashx" />
                                    </Proxy>
                                    <Reader>
                                        <ext:JsonReader Root="cities" TotalProperty="total">
                                            <Fields>
                                                <ext:RecordField Name="Name" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                            </Store>
                        </ext:ComboBox>
                        <ext:TextField ID="tfPhone" runat="server" FieldLabel="Phone" AnchorHorizontal="45%" />
                        <ext:TextField ID="tfFax" runat="server" FieldLabel="Fax" AnchorHorizontal="45%" />
                        <ext:Checkbox ID="cbBill" runat="server" FieldLabel="Bill To">
                        </ext:Checkbox>
                        <ext:Checkbox ID="cbSurvey" runat="server" FieldLabel="Customer Survey">
                        </ext:Checkbox>
                    </Items>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="Button4" runat="server" Text="Save" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="ContactAdd">
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="Button6" runat="server" Text="Reset">
                    <Listeners>
                        <Click Handler="#{FrmContact}.getForm().reset();#{AddContact}.hide();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Window>
    Cities.ashx

    You can replace the procedure here with something that returns a json list just for an example

    Imports System.Web
    Imports System.Web.Services
    Imports Ext.Net
    Imports Oracle.DataAccess.Client
    
    Public Class Cities
        Implements System.Web.IHttpHandler
    
        Protected Function ReturnOracleConnection() As OracleConnection
    
            Dim serverInstance As String = System.Configuration.ConfigurationManager.AppSettings("server")
            If serverInstance = Nothing Then
                Return Nothing
                Exit Function
            End If
            Dim cn As New OracleConnection("DATA SOURCE=" + serverInstance + ";PERSIST SECURITY INFO=True;USER ID=XXXX;PASSWORD=XXXX")
            Return cn
        End Function
    
    
        Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
    
            context.Response.ContentType = "text/json"
    
            Dim start = 0
            Dim limit = 10
            Dim query = String.Empty
    
            If Not String.IsNullOrEmpty(context.Request("start")) Then
                start = Integer.Parse(context.Request("start"))
            End If
    
            If Not String.IsNullOrEmpty(context.Request("limit")) Then
                limit = Integer.Parse(context.Request("limit"))
            End If
    
    
            If Not String.IsNullOrEmpty(context.Request("query")) Then
                query = context.Request("query")
            End If
    
            Dim cities As Paging(Of ComboList) = CitiesPaging(start, limit, query)
    
            context.Response.Write(String.Format("{{total:{1},'cities':{0}}}", JSON.Serialize(cities.Data), cities.TotalRecords))
    
        End Sub
    
        Public Function CitiesPaging(ByVal start As Integer, ByVal limit As Integer, ByVal filter As String) As Paging(Of ComboList)
            Dim Cities As List(Of ComboList) = Return_City(filter)
    
            'If Not String.IsNullOrEmpty(filter) AndAlso filter <> "*" Then
            '    Cities.RemoveAll(Function(city__1) Not city__1.Name.ToLower().StartsWith(filter.ToLower()))
            'End If
    
            If (start + limit) > Cities.Count Then
                limit = Cities.Count - start
            End If
    
            Dim rangeCities As List(Of ComboList) = If((start < 0 OrElse limit < 0), Cities, Cities.GetRange(start, limit))
    
            Return New Paging(Of ComboList)(rangeCities, Cities.Count)
        End Function
    
        Public Function Return_City(ByVal filter As String) As List(Of ComboList)
            Dim data As New List(Of ComboList)
    
            Dim OrclCmd2 As New OracleCommand("XXDBI_AM_VALIDATION.GET_CITIES", ReturnOracleConnection)
            OrclCmd2.CommandType = CommandType.StoredProcedure
            OrclCmd2.Parameters.Add("RETURN_DATA", OracleDbType.RefCursor, ParameterDirection.ReturnValue)
            OrclCmd2.Parameters.Add("P_CITY_NAME", OracleDbType.Varchar2, filter, ParameterDirection.Input)
    
            Dim OrclDA As New OracleDataAdapter(OrclCmd2)
    
            Dim dt As New DataTable
            OrclDA.Fill(dt)
    
            If dt.Rows.Count <> 0 Then
                For Each dr As DataRow In dt.Rows
                    data.Add(New ComboList(dr("CITY_NAME").ToString, dr("CITY_NAME").ToString))
                Next
            End If
    
            OrclCmd2.Connection.Close()
            OrclDA.Dispose()
            OrclCmd2.Dispose()
    
            Return data
        End Function
    
        ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
            Get
                Return False
            End Get
        End Property
    
    End Class
  4. #4
    Hi,

    I cannot reproduce the problem, here is my test case uses http handler from https://examples1.ext.net/#/Form/Com...Custom_Search/
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void ContactAdd(object sender, DirectEventArgs e)
        {
        }
    </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 runat="server">
        <title>ComboBox with Template - Ext.NET Examples</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Window runat="server" ID="AddContact" Height="465" Width="500" Title="Contact Maintenance"
            Resizable="false" Maximizable="false" Minimizable="false" Hidden="true" InitCenter="true"
            Modal="true" Border="false" Layout="Form">
            <Items>
                <ext:FormPanel runat="server" ID="FrmContact" PaddingSummary="5">
                    <Items>
                        <ext:TextField ID="tfName" runat="server" FieldLabel="Name" AllowBlank="false" AnchorHorizontal="100%" />
                        <ext:TextField ID="tfTitle" runat="server" FieldLabel="Title" AllowBlank="false"
                            AnchorHorizontal="100%" />
                        <ext:TextField ID="tfDepartment" runat="server" FieldLabel="Department" AllowBlank="false"
                            AnchorHorizontal="100%" />
                        <ext:TextField ID="tfEmail" runat="server" Vtype="email" FieldLabel="Email" AnchorHorizontal="100%" />
                        <ext:TextField ID="tfAddress1" runat="server" FieldLabel="Address1" AnchorHorizontal="100%" />
                        <ext:TextField ID="tfAddress2" runat="server" FieldLabel="Address2" AnchorHorizontal="100%" />
                        <ext:ComboBox runat="server" ID="tfCity" Editable="true" TypeAhead="false" FieldLabel="City"
                            AnchorHorizontal="70%" DisplayField="Common" LoadingText="Searching..." ValueField="Common"
                            ForceSelection="true" PageSize="10" HideTrigger="false" MinChars="1">
                            <Store>
                                <ext:Store ID="Store1" runat="server" AutoLoad="false">
                                    <Proxy>
                                        <ext:HttpProxy Method="POST" Url="Plants.ashx" />
                                    </Proxy>
                                    <Reader>
                                        <ext:JsonReader Root="plants" TotalProperty="total">
                                            <Fields>
                                                <ext:RecordField Name="Common" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                            </Store>
                        </ext:ComboBox>
                        <ext:TextField ID="tfPhone" runat="server" FieldLabel="Phone" AnchorHorizontal="45%" />
                        <ext:TextField ID="tfFax" runat="server" FieldLabel="Fax" AnchorHorizontal="45%" />
                        <ext:Checkbox ID="cbBill" runat="server" FieldLabel="Bill To">
                        </ext:Checkbox>
                        <ext:Checkbox ID="cbSurvey" runat="server" FieldLabel="Customer Survey">
                        </ext:Checkbox>
                    </Items>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="Button4" runat="server" Text="Save" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="ContactAdd">
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="Button6" runat="server" Text="Reset">
                    <Listeners>
                        <Click Handler="#{FrmContact}.getForm().reset();#{AddContact}.hide();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Window>
        
        <ext:Button ID="Button1" runat="server" Text="Open the window" Handler="function(){AddContact.show();}">
                    
                </ext:Button>
        </form>
    </body>
    </html>
  5. #5
    Ok I have a working example for you.

    After it's loaded, click the submit button, message box will appear.

    Then click the the dropdown to load the values, and click the button again, there will be an error, or it won't work. (note I capture my error in my global config file so I have it emailing to me, nothing shows in debug mode)

    test.aspx
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test.aspx.vb" Inherits="Enterprise_Management_System.test" %>
    
    <%@ 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>
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <form id="form1" runat="server">
          <ext:FormPanel runat="server" ID="FrmContact" PaddingSummary="5">
                    <Items>
                        <ext:ComboBox runat="server" ID="tfCity" Editable="true" TypeAhead="false" FieldLabel="City"
                            AnchorHorizontal="70%" DisplayField="Name" LoadingText="Searching..." ValueField="Name"
                            ForceSelection="true" PageSize="10" HideTrigger="false" MinChars="1">
                            <Store>
                                <ext:Store ID="Store1" runat="server" AutoLoad="false">
                                    <Proxy>
                                        <ext:HttpProxy Method="POST" Url="Test.ashx" />
                                    </Proxy>
                                    <Reader>
                                        <ext:JsonReader Root="test" TotalProperty="total">
                                            <Fields>
                                                <ext:RecordField Name="Name" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                            </Store>
                        </ext:ComboBox>
                    </Items>
                     <Buttons>
                <ext:Button ID="Button4" runat="server" Text="Save" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="ContactAdd">
                        </Click>
                    </DirectEvents>
                </ext:Button> 
            </Buttons>
                </ext:FormPanel>
        </form>
    </body>
    </html>
    code behind test.apsx.vb
    Imports Ext.Net
    Imports Oracle.DataAccess.Client
    
    Public Class test
        Inherits Enterprise_Management_System.BasePage
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    
    
        Public Sub ContactAdd(ByVal sender As Object, ByVal e As DirectEventArgs)
            'WILL FAIL, CAN NOT ACCESS CONTACTADD DirectEvent
            Dim test As String = "TEST SUBMIT"
            If tfCity.Text.Length > 0 Then
                test = tfCity.Text.ToString
            End If
            Ext.Net.ExtNet.MessageBox.Alert("Value of Combo", test).Show()
        End Sub
    
    End Class
    Test.ashx.vb Generic handler
    Imports System.Web
    Imports System.Web.Services
    Imports Ext.Net
    
    Public Class Test1
        Implements System.Web.IHttpHandler
    
        Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
    
            context.Response.ContentType = "text/json"
    
            Dim start = 0
            Dim limit = 10
            Dim query = String.Empty
    
            If Not String.IsNullOrEmpty(context.Request("start")) Then
                start = Integer.Parse(context.Request("start"))
            End If
    
            If Not String.IsNullOrEmpty(context.Request("limit")) Then
                limit = Integer.Parse(context.Request("limit"))
            End If
    
    
            If Not String.IsNullOrEmpty(context.Request("query")) Then
                query = context.Request("query")
            End If
    
            Dim test As Paging(Of TestList) = TestPaging(start, limit, query)
    
            context.Response.Write(String.Format("{{total:{1},'test':{0}}}", JSON.Serialize(test.Data), test.TotalRecords))
    
        End Sub
    
        Public Function TestPaging(ByVal start As Integer, ByVal limit As Integer, ByVal filter As String) As Paging(Of TestList)
            Dim Test As List(Of TestList) = Return_test()
    
            If (start + limit) > Test.Count Then
                limit = Test.Count - start
            End If
    
            Dim rangeTest As List(Of TestList) = If((start < 0 OrElse limit < 0), Test, Test.GetRange(start, limit))
    
            Return New Paging(Of TestList)(rangeTest, Test.Count)
        End Function
    
        Public Function Return_test() As List(Of TestList)
            Dim data As New List(Of TestList)
    
            
            data.Add(New TestList("Testin1", "T1"))
            data.Add(New TestList("Testin2", "T2"))
            data.Add(New TestList("Testin3", "T3"))
            data.Add(New TestList("Testin4", "T4"))
            data.Add(New TestList("Testin5", "T5"))
            data.Add(New TestList("Testin6", "T6"))
            data.Add(New TestList("Testin7", "T7"))
             
    
            Return data
        End Function
    
        ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
            Get
                Return False
            End Get
        End Property
    
        Public Class TestList
            Public Sub New()
            End Sub
    
            Public Sub New(ByVal ID As String, ByVal Name As String)
                _ID = ID
                _Name = Name
            End Sub
    
            Private Property _ID As String
            Public Property ID() As String
                Get
                    Return _ID
                End Get
                Set(ByVal value As String)
                    _ID = value
                End Set
            End Property
    
            Private Property _Name As String
            Public Property Name() As String
                Get
                    Return _Name
                End Get
                Set(ByVal value As String)
                    _Name = value
                End Set
            End Property
        End Class
    End Class
    Again the error I get from my global Application Error:

    I
    nner Exception Type :System.NullReferenceException
    Current User :Non-Authenticated User
    Inner Exception :Object reference not set to an instance of an object.
    Inner Source :Ext.Net.ComboBox
    Inner Stack Trace : at Ext.Net.ComboBox.LoadPostData(String postDataKey, NameValueCollection postCollection) at Ext.Net.Field.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    Last edited by geoffrey.mcgill; Dec 15, 2010 at 7:43 PM. Reason: please use [CODE] tags
  6. #6
    Hi,

    Fixed in SVN, please update
  7. #7
    Rev. 3375 fixed my combobox issue.

    Great product. Thanks!
  8. #8
    That corrected my issues. :)

    Thanks!

Similar Threads

  1. Replies: 5
    Last Post: Mar 19, 2014, 3:35 AM
  2. Replies: 1
    Last Post: Jun 09, 2011, 7:04 PM
  3. [CLOSED] Adding a button directevent in a directevent method
    By ogokgol in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 31, 2011, 10:29 AM
  4. [CLOSED] IE9 issues
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Mar 28, 2011, 7:06 PM
  5. Replies: 2
    Last Post: Oct 22, 2010, 11:04 AM

Posting Permissions