Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AJAX help: Popup control extender not working

Status
Not open for further replies.

DatabaseDude

Programmer
Nov 7, 2005
112
US
I have a gridview, in which there's a notepad icon as an image. When the user mouses over the icon, I want a pop-up to display any notes associated with that record. However, nothing happens.

Gridview code:
Code:
    <asp:ScriptManager id="ScriptManager1" enablepartialrendering ="true" runat="server" />
    <asp:GridView ID="gridRMAs" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataKeyNames="RmaID" DataSourceID="SqlDataSourceRMAs" EmptyDataText="No data found for the search results!" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
        <Columns>
            <asp:BoundField DataField="RmaID" HeaderText="RMA #" InsertVisible="False" ReadOnly="True"
                SortExpression="RmaID" />
            <asp:BoundField DataField="Status" HeaderText="Status" ReadOnly="True" SortExpression="Status" />
            <asp:BoundField DataField="Repair" HeaderText="Repair" ReadOnly="True" SortExpression="Repair" />
            <asp:BoundField DataField="Type" HeaderText="Type" ReadOnly="True" SortExpression="Type" />
            <asp:BoundField DataField="RmaCreateDate" HeaderText="Created" SortExpression="RmaCreateDate" />
            <asp:BoundField DataField="RmaRequestedBy" HeaderText="Requested By" SortExpression="RmaRequestedBy" />
            <asp:BoundField DataField="RmaReleaseNo" HeaderText="Release #" SortExpression="RmaReleaseNo" />
            <asp:BoundField DataField="RmaTicketNo" HeaderText="Ticket #" SortExpression="RmaTicketNo" />
            <asp:BoundField DataField="RmaPartNo" HeaderText="Part #" SortExpression="RmaPartNo" />
            <asp:BoundField DataField="RmaQty" HeaderText="Qty" SortExpression="RmaQty" />
            <asp:BoundField DataField="RmaSerialNo" HeaderText="Serial #" SortExpression="RmaSerialNo" />
            <asp:BoundField DataField="Reason" HeaderText="Reason" ReadOnly="True" SortExpression="Reason" />
            <asp:CheckBoxField DataField="RmaBoxIsOpen" HeaderText="Box Open?" SortExpression="RmaBoxIsOpen" />
            <asp:BoundField DataField="Location" HeaderText="Location" ReadOnly="True" SortExpression="Location" />
            <asp:BoundField DataField="Notes" HeaderText="Notes" ReadOnly="True" SortExpression="Notes" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Image ID="Image1" ImageUrl="~/images/notepad.gif" runat="server" />
                    <cc1:PopupControlExtender 
                        ID="PopupControlExtender1" 
                        runat="server" 
                        DynamicServiceMethod="GetDynamicContent"
                        DynamicContextKey='<%# Eval("RmaId") %>'
                        DynamicControlID="Panel1"
                        TargetControlID="Image1"
                        PopupControlID="Panel1"
                        Position="left">
                    </cc1:PopupControlExtender>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="RmaOverShipmentDetails" HeaderText="Over Shipment Details"
                SortExpression="RmaOverShipmentDetails" />
            <asp:HyperLinkField 
                DataNavigateUrlFormatString=
               "editrequest.aspx?rmaid={0}"        
                DataNavigateUrlFields="RmaId" Text="Edit"/>
                
        </Columns>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingRowStyle BackColor="#F7F7F7" />
    </asp:GridView>

Codebehind for gridview page:
Code:
    <System.Web.Services.WebMethodAttribute()> <System.Web.Script.Services.ScriptMethodAttribute()> Public Shared Function GetDynamicContent(ByVal contextKey As System.String) As System.String
        Dim StrHtml As New StringBuilder

        Using Conn As New SqlConnection( _
            ConfigurationManager.ConnectionStrings("StiApps").ConnectionString)
            Conn.Open()

            Using Comm As New SqlCommand
                With Comm
                    .CommandText = "dbo.GetRmaNotes"
                    .CommandType = CommandType.StoredProcedure
                    .Connection = Conn
                    .Parameters.AddWithValue("@IntRmaId", Convert.ToInt32(contextKey))
                End With

                Dim Dr As SqlDataReader
                Dr = Comm.ExecuteReader

                If Dr.HasRows Then
                    StrHtml.Append("<table>")

                    StrHtml.Append("<tr><th>Created</th><th>Note:</th><th>Entered By</th></tr>")

                    Dim Row As DataRow

                    For Each Row In Dr
                        StrHtml.Append("<tr>")
                        StrHtml.Append("<td>" & Row("RmaNoteEntered") & "</td>")
                        StrHtml.Append("<td>" & Row("RmaNote") & "</td>")
                        StrHtml.Append("<td>" & Row("RmaNoteEnteredBy") & "</td>")
                        StrHtml.Append("</tr>")
                    Next

                    StrHtml.Append("</table>")
                Else
                    StrHtml.Append("<i>This RMA has no notes</i>")
                End If
            End Using
        End Using

        Return StrHtml.ToString


    End Function

    Protected Sub gridRMAs_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridRMAs.RowCreated
        If e.Row.RowType = DataControlRowType.DataRow Then

            Dim Pce As AjaxControlToolkit.PopupControlExtender = _
                e.Row.FindControl("PopupControlExtender1")

            Dim StrBehaviorId As String = String.Concat("Pce", e.Row.RowIndex)
            Pce.BehaviorID = StrBehaviorId

            Dim Img As Image = e.Row.Cells(1).FindControl("Image1")

            Dim StrOnMouseOverScript As String = _
                String.Format("$find('{0}').showPopup();", StrBehaviorId)

            Dim StrOnMouseOutScript As String = _
                String.Format("$find('{0}').hidePopup();", StrBehaviorId)

            Img.Attributes.Add("onmouseover", StrOnMouseOverScript)
            Img.Attributes.Add("onmouseout", StrOnMouseOutScript)
        End If
    End Sub


JavaScript error from browser:
Code:
Line: 112
Char: 1
Error: Object expected
Code: 0


I followed the example in but since it's in C# (I'm a VB person) I may have missed something important.

Thanks in advance,
Bryant
 
If you are getting a javascript error, I suggest you use the FireFox javascript Error Console to find out the exact error. You may also need to ask for further assistance in the javascript forum by providing the rendered source.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
I can see a script manager, but dont you need to wrap the GridView inside an UpdateControl.

At the moment, the Script Manager is calling out to update, but there is nothing there to process the update command...

K
 
Mark -- The Javascript error appears only in IE. In Firefox, no error appears, though I did find several listed in the console you suggested. I wasn't sure if it was a browser dependent problem.

Kalisto -- The example from which I've been working does not have an UpdateControl, so I don't have it in mine.
 
I wasn't sure if it was a browser dependent problem.
Yes, that's a possibility. There's a web developer toolbar for IE that may help track down the problem. If not, try asking in the javascript forum.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top