[英]Calling Javascript function with multiple parameters from gridview hyperlink
I am getting the following error when trying to call a javascript function from a hyperlink within a gridview. 尝试从gridview中的超链接调用javascript函数时出现以下错误。
JavaScript critical error in (unknown source location) JavaScript严重错误(来源位置未知)
SCRIPT1006: Expected ')' 脚本1006:预期')'
The alert in the function doesn't even show. 该功能中的警报甚至不会显示。 Thanks in advance. 提前致谢。
function EditResource(sResourceID, sTravelMName, sChronoMName) {
alert("test");
var options = {
url: "http://192.168.9.12:1002/SitePages/ResourceEdit.aspx?ResourceID=" + sResourceID + "&TravelManagerName=" + sTravelMName+ "&ChronoManagerName=" +sChronoMName,
title: "Edit Resource",
autoSize: true,
dialogReturnValueCallback: DialogCallback
};
SP.UI.ModalDialog.showModalDialog(options);
}
The hyperlink code 超链接代码
<asp:HyperLink runat="server" CssClass="padding5" ID="hpEdit" ToolTip="Set Manager" ImageUrl="../_layouts/15/images/Test/Icons/icon_edit.png" NavigateUrl='<%# "javascript:EditResource(" + Eval("Resource_ID") + "," + Eval("Travel_Manager_Full_Name") + "," + Eval("Chrono_Manager_Full_Name")+")" %>'></asp:HyperLink>
Your function invocation code has errors... 您的函数调用代码有错误...
href="javascript:EditResource(19,Joline Farquhar,Pikes)"
notice the missing quotes around the name. 注意名称周围缺少的引号。 It needs to look like this: 它需要看起来像这样:
href="javascript:EditResource(19,'Joline Farquhar','Pikes')"
您需要在javascript调用中对字符串变量进行转义。
javascript:EditResource(19,'Joline Farquhar','Pikes')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.