I am attempting to pass an id and a code though a javascript method onclick in vb.net. I am getting the error 'example string' is not defined. All the other variable will pass though without problem. Maybe I have the syntax wrong. I'm not sure.
For Each skillDetail As StationEmployeSkill In empDetail.EmployeeSkills
If skillDetail.IsExpired And GlobalsFSiA.HighlightSkillsAfterExpiring > -1 Then
td.Text += "<a href='#' onclick='EndSkill(" & empDetail.EmployeeId & "," & skillDetail.SkillCode & ");'><font color=""red"">" & skillDetail.SkillCode & " </font></a>"
ElseIf skillDetail.ExpiresSoon And GlobalsFSiA.HighlightSkillsBeforeExpiring > -1 Then
td.Text += "<a href='#' onclick='EndSkill(" & empDetail.EmployeeId & "," & skillDetail.SkillCode & ");'><font color=""blue"">" & skillDetail.SkillCode & " </font></a>"
ElseIf skillDetail.ForeColor <> "" Then
td.Text += "<a href='#' onclick='EndSkill(" & empDetail.EmployeeId & "," & skillDetail.SkillCode & ");'><font color=""" & skillDetail.ForeColor & """>" & skillDetail.SkillCode & " </a>"
Else
td.Text += "<a href='#' onclick='EndSkill(" & empDetail.EmployeeId & "," & skillDetail.SkillCode & ");'><font color=""black"">" & skillDetail.SkillCode & " </font></a>"
End If
Next
td.Text += "<a href='#' onclick='AddSkill(" & empDetail.EmployeeId & ");'><font color=""green"">+ </font></a>"
tr.Cells.Add(td)
Classic quotes issue, You should pass empDetail.EmployeeId
and skillDetail.SkillCode
with in quotes to be treated as string parameter. Otherwise they will be treated as variables which obviously you have not defined thus will get the error.
Here I have esacped quotes
td.Text += "<a href='#' onclick='EndSkill(""" & empDetail.EmployeeId & """,""" & skillDetail.SkillCode & """);'>"
Escape double-quotes in VB is by doubling the double-quotes:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.