DatabaseDude
Programmer
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:
Codebehind for gridview page:
JavaScript error from browser:
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
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