none
ModalPopup, UpdatePanel, Javascript "Object Required" Error RRS feed

  • Question

  • A page in my asp.net web app has a modal popup which contains a listbox that must be populated on the fly.  The page contains a treeview control, right clicking a node on the treeview calls up a context menu, and if the user clicks on "Add Pretask", the popup form appears, listing items which vary depending upon which node was clicked.  

    The listbox is contained within an UpdatePanel which was inserted so that the list could be populated without reposting the entire page.  I developed this popup, tested it, and it appeared to be working properly.  I was patting myself on the back for a job well done when I happened to press a key on the computer keyboard.  The app crashed with the following error message:  

    "Unhandled exception at line 1010, column 1 in http://localhost:55109/PPM/ScriptResource.axd?d=8GNeJYrV145FFZwe3zZTQTMdSqo5ZWiNHMcMCdX41b_dp65omt53usfcChKlDkhIbPdehfLSEKVkXbwQruOiDLDfxhVjDQZOQZDVfHxfkhrBY3rHZVHxg2I6VQGIFSKL2AhGUprc1gW7X0t1_Q79OAckMdH-JliDUkID4lzcsT8Bfkxn0&t=1e478eba

    0x800a138f - JavaScript runtime error: Object expected"

    I have been wrestling with this one for days.  Thank you very much for any help.

    Here is the relevant markup from the:

                                 

        <!-- POPUP FOR ADDING PRETASKS TO SELECTED TASK -->
         <a href="#" style="display:none;" onclick="javascript:return false" id="hidlinkAddPretask" 
        runat="server">dummy</a>

        <cc1:ModalPopupExtender ID="mpePretask" runat="server"  PopupControlID="pnlPretask" TargetControlID="hidlinkAddPretask"
             CancelControlID="btnCancelPretask" ></cc1:ModalPopupExtender>

        <asp:Panel ID="pnlPretask" runat="server" CssClass="popupPanel" Width="40%">

            <!-- Panel within pnlPretask contains list of selected pretasks. -->
             <asp:panel runat="server" ID="pnlPretaskList" Visible="false">
                <asp:BulletedList ID="blPretasks" runat="server">
                </asp:BulletedList>
            </asp:panel>


                    <asp:HiddenField runat="server" ID="hidPostTaskID" Visible="true" />

                    Before <b>"<asp:Label ID="lblAddPretask" runat="server"></asp:Label>"</b> can be completed, I must:
                    <br /><br />

            <asp:UpdatePanel ID="updPretask" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
               <ContentTemplate>

                   <asp:ListBox ID="lboxPretask" runat="server" Width="80%" Height="200px"
                         ToolTip="Select one or more tasks that must be completed before..." AutoPostBack="false"
                         SelectionMode="Multiple">
                  </asp:ListBox>

                </ContentTemplate>
            </asp:UpdatePanel>

           <br /><br />
            <asp:UpdateProgress ID="UpdateProgress4" runat="server" DisplayAfter="0">
                <ProgressTemplate>
                    <img src="images/progress.gif" alt="" />&nbsp;Updating...</ProgressTemplate>
            </asp:UpdateProgress>

            <asp:Label runat="server" ID="lblErrPretask" Font-Bold="True" ForeColor="Red" />
            <br />
            <asp:Button ID="btnAddAnotherPretask" runat="server" Text="Save and Add Another" />
            <asp:Button ID="btnSavePretask" runat="server" Text="Save" />
            <asp:Button ID="btnCancelPretask" runat="server" Text="Cancel"   />
        </asp:Panel>

    The popup is called up from the server in vb:

                'Repopulate lboxPretask
                Dim ID As String = e.NodeClicked.Attributes("TaskID").ToString
                PretaskSelectList(ID)
                updPretask.Update()
                mpePretask.Show()

    And this routine populates the listbox:

        Private Sub PretaskSelectList(ByVal TaskID As Integer)

            'Populate drop down list lboxPretask with all Owner's undone, active tasks
            'that are not for TaskID is not a prerequisite.  

            Dim strConn As String = ConfigurationManager.ConnectionStrings("PPMConnectionString").ConnectionString
            Dim cnn As SqlConnection = New SqlConnection(strConn)

            cnn.Open()

            'Get two result sets from uspPretaskPickList
            Dim sql As String = "execute dbo.uspPretaskPickList " & TaskID.ToString

            Dim cmd As SqlCommand = New SqlCommand(sql, cnn)

            'Result set #1 - Tasks from current Goal
            Dim rdr As SqlDataReader = cmd.ExecuteReader()
            Dim Itm As ListItem

            With lboxPretask
                .Enabled = True

                .Items.Clear()

                'Add a default item, #0
                Itm = New ListItem("ADD NEW TASK", "0")
                Itm.Attributes.Add("Style", "Font-Weight:Bold")
                .Items.Add(Itm)

                'Insert a separator if data reader has any records
                Dim separator As New ListItem("-------------------------", "")
                separator.Attributes.Add("disabled", "true")

                If rdr.HasRows Then
                    .Items.Add(separator)
                End If

                'Add each member of 1st result set, using lboxPretask.Items.Add(New ListItem(TaskName, TaskID))
                Do While rdr.Read
                    Itm = New ListItem(rdr("TaskName"), rdr("TaskID").ToString)
                    'Each item should be Bold. 
                    Itm.Attributes.Add("Style", "Font-Weight:Bold")
                    .Items.Add(Itm)
                Loop

                'Add dividing line, Pretask.Items.Add("------------", "-1")
                separator.Attributes.Add("disabled", "true")
                .Items.Add(separator)

                'Results set #2 - Tasks from other or no goal
                rdr.NextResult()

                'Add each member of 2nd result set, using lboxPretask.Items.Add(New ListItem(TaskName, TaskID))
                Do While rdr.Read
                    Itm = New ListItem(rdr("TaskName"), rdr("TaskID").ToString)
                    .Items.Add(Itm)
                Loop

            End With

            rdr.Close()
            cnn.Close()

            rdr = Nothing
            cnn = Nothing

            lboxPretask.ClearSelection()

        End Sub


    Sheldon Penner


    Friday, April 3, 2020 9:25 AM

All replies

  • Hello,

    The best place to ask this question is in the ASP.NET forum


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, April 3, 2020 9:38 AM