1

I am getting the following error when trying to call a javascript function from a hyperlink within a gridview.

JavaScript critical error in (unknown source location)

SCRIPT1006: Expected ')'

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>
2
  • What's the javascript function call look like in the actual HTML? Commented Aug 26, 2013 at 13:53
  • The call is in the code snippet of the hyperlink above. I'm calling it from the NavigateUrl property. Here is the actual html when the page is rendered href="javascript:EditResource(19,Joline Farquhar,Pikes)" Commented Aug 26, 2013 at 13:56

2 Answers 2

1

You'll need to escape the string variables in your javascript call.

javascript:EditResource(19,'Joline Farquhar','Pikes')
Sign up to request clarification or add additional context in comments.

Comments

1

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')"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.