in my asp.net application (vb code behind) I have a page that has an iframe on the right side. The left side of the page (will refer to this as the parent page, the iframe will be the iframe) has a few tables, and when certain cells are clicked, it changes the src of the iframe using javascript to show a detailed account inside the iframe of the entry they clicked on. Inside the iframe at the top, there is a breadcrumb trail that shows the entries that must be followed in order to get to this entry (its sort of like a tree, there are different levels of entries and each one below is linked to a parent above, etc). These links are just simple html links that are created using a function on the VB side. My issue is that when I click on an entry from the parent page, everything loads correctly, but when I click on a link from with in the breadcrumb trail in the iframe – When scrolling my mouse over some images, I get an error with my javascript function that handles the mouseover. Both ways (changing the src or clicking a link in the frame) call the same page and function. I believe I have found the issue – when clicking from the parent window – the javascript call for the mouse over looks like this.
onmouseover="imgOv(this, '../images/modify.gif')"
When clicking on the link in the iframe, the mouseover looks like this.
onmouseover="imgOv(this, '../images/level_over.gif')"
Here is the code that generates this html. Can anyone see why my single quotes are turning into ' instead of just the quote like when the frames src is changed?
The code:
Here is navSpot – a placeholder in the details page. The info here is loaded from another VB library
<asp:PlaceHolder id="NavSpot" Runat="server"></asp:PlaceHolder>
on load of the details page (the details page is the page in the iframe, if clicked from the parent, the src of the frame is changed to the details page, if clicked from the link, it just uses an href to call the page). here is the code that handles the navSpot
Dim myCtrl As UserControl = LoadControl("../include/NavDetailScreens.ascx")
myCtrl.ID = "navControl"
NavSpot.Controls.Add(myCtrl)
And here is the function that is called when NavDetailScreens.ascx is called – I am positive that the same exact parameters are being passed into the SP, and that there is no difference in changing the src or clicking the link already in the iframe (in regards to the parameters used for the stored procedure). The error section seems to come at the end, specifically the three lines towards the end of the sub, inside the if that starts with “If DS.Item(“activity_enable”) = 1 Then” – it seems like this is when the single quotes are turned into the & # 39; (used spaces so it didnt auto adjust to a single quote – no spaces in actual string that is in the JS function)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Request.QueryString("standalone") <> "true" Then
Dim strConn As String
strConn = WebConfigurationManager.AppSettings.Item("ConnectionString")
Dim objConn As SqlConnection
objConn = New SqlConnection(strConn)
Dim myCmd As SqlCommand
myCmd = New SqlCommand
myCmd.Connection = objConn
myCmd.CommandType = CommandType.StoredProcedure
myCmd.CommandText = "SPNavigation"
Dim lnChildCat As Integer
Dim prmEntityID As New SqlParameter("@entityID", SqlDbType.BigInt)
prmEntityID.Value = Request.QueryString("taskgrpid")
Dim prmEntityCat As New SqlParameter("@entityCat", SqlDbType.Int)
If Request.QueryString("taskgrpid") = "" Then
prmEntityCat.Value = 35
lnChildCat = 26
prmEntityID.Value = DBNull.Value
ElseIf Request.QueryString("taskgrpcategory") = Request.QueryString("ptaskgrpcategory") Then
If Request.QueryString("taskgrpcategory") = 26 Then
prmEntityCat.Value = 34
lnChildCat = 34
ElseIf Request.QueryString("taskgrpcategory") = 10 Then
prmEntityCat.Value = 11
lnChildCat = 11
ElseIf Request.QueryString("taskgrpcategory") = 11 Then
prmEntityCat.Value = 12
lnChildCat = 12
ElseIf Request.QueryString("taskgrpcategory") = 12 Then
prmEntityCat.Value = 13
lnChildCat = 13
ElseIf Request.QueryString("taskgrpcategory") = 35 Then
prmEntityCat.Value = 35
lnChildCat = 26
ElseIf Request.QueryString("taskgrpcategory") = 34 Then
prmEntityCat.Value = 10
lnChildCat = 11
End If
Else
If Request.QueryString("taskgrpcategory") = 26 Then
prmEntityCat.Value = 26
lnChildCat = 34
Else
prmEntityCat.Value = Request.QueryString("taskgrpcategory")
lnChildCat = Request.QueryString("taskgrpcategory")
End If
End If
Dim prmIsMilestone As New SqlParameter("@isMilestone", SqlDbType.Int)
If Request.QueryString("milestone") = "true" Then
prmIsMilestone.Value = 1
Else
prmIsMilestone.Value = 0
End If
Dim prmResID As New SqlParameter("@resid", SqlDbType.Int)
prmResID.Value = Session.Item("user_id")
myCmd.Parameters.Add(prmEntityID)
myCmd.Parameters.Add(prmEntityCat)
myCmd.Parameters.Add(prmResID)
myCmd.Parameters.Add(prmIsMilestone)
Dim DS As SqlDataReader
objConn.Open()
DS = myCmd.ExecuteReader
Dim objRow As TableRow
objRow = New TableRow
Dim objCell As TableCell
Dim lc As LiteralControl
Dim dynImg As Image
While DS.Read
objCell = New TableCell
lc = New LiteralControl
lc.Text = "<br>" & DS.Item("act_name")
dynImg = New Image
If Request.QueryString("mode") = "create" Then
If IsDBNull(DS.Item("act_frm_params")) = False Then
If Request.QueryString("milestone") = "true" Then
If DS.Item("act_frm_params") = "&mode=create&milestone=true" And CInt(lnChildCat) = CInt(DS.Item("act_task_category")) Then
dynImg.ImageUrl = DS.Item("act_img_name_edit")
Else
dynImg.ImageUrl = DS.Item("act_img_name_disabled")
End If
Else
If DS.Item("act_frm_params") = "&mode=create" And CInt(lnChildCat) = CInt(DS.Item("act_task_category")) Then
dynImg.ImageUrl = DS.Item("act_img_name_edit")
Else
dynImg.ImageUrl = DS.Item("act_img_name_disabled")
End If
End If
Else
dynImg.ImageUrl = DS.Item("act_img_name_disabled")
End If
ElseIf Request.QueryString("mode") = "edit" Then
If IsDBNull(DS.Item("act_frm_params")) = False Then
If Request.QueryString("milestone") = "true" Then
If DS.Item("act_frm_params") = "&mode=edit&milestone=true" Then
dynImg.ImageUrl = DS.Item("act_img_name_edit")
Else
dynImg.ImageUrl = DS.Item("act_img_name_disabled")
End If
Else
If DS.Item("act_frm_params") = "&mode=edit" And CInt(Request.QueryString("taskgrpcategory")) = CInt(DS.Item("act_task_category")) Then
dynImg.ImageUrl = DS.Item("act_img_name_edit")
Else
dynImg.ImageUrl = DS.Item("act_img_name_disabled")
End If
End If
Else
dynImg.ImageUrl = DS.Item("act_img_name_disabled")
End If
Else
If DS.Item("activity_enable") = 1 Then
dynImg.ImageUrl = DS.Item("act_img_name")
dynImg.Style.Add("cursor", "hand")
dynImg.Attributes.Add("onmouseover", "imgOv(this, '" & DS.Item("act_img_name_over") & "')")
dynImg.Attributes.Add("onmouseout", "imgOu(this, '" & DS.Item("act_img_name") & "')")
dynImg.Attributes.Add("onclick", "imgclick('" & DS.Item("act_frm_name") & "', '" & DS.Item("act_frm_params") & "" & "', " & DS.Item("act_task_category") & ")")
Else
dynImg.ImageUrl = DS.Item("act_img_name_disabled")
End If
End If
objCell.Controls.Add(dynImg)
objCell.Controls.Add(lc)
objCell.CssClass = "infotext2"
objCell.VerticalAlign = VerticalAlign.Top
objCell.Width = Unit.Pixel(50)
objRow.Cells.Add(objCell)
End While
DS.Close()
objConn.Close()
tlbNav.Rows.Add(objRow)
End If
End Sub
Thanks again for your help.
Edit: when changing the single quotes to regular quotes, they are being replaced with & quote instead of & # 39 – so this was not a solution.
Edit 2: seems like this is cause of .net 4.0 and a security update – and rolling back to 3.5 would fix this issue, but this is not an option. any other solutions to stop this conversion?
was able to solve this issue by instead of clicking on the links with an href, changed them to call a javascript function in the parent page, which changes the src of the iframe instead, and the comma’s are not being converted this way.