Open display form as dialog box from hyperlinks in a gridview

Last couple days, I was trying to work on a gridview the display external list items. I do not have much knowledge of the area. After I took care the new item dialog, I get another issue for exist items. I use HyperLinkField to generate a hyperlink for each external item and want users open item sin a dialog box.

Then I added the following script to a content edit on the DispForm.aspx.

When I click the hyperlink, the default display form (not the dialog) is open. However, when I try to edit the page and modify the script, the dialog box popup with the correct item? It seems the javascript is doing something, but not do the right way. I wish someone can help me on this. Sorry for keep post my questions for the same object recently. Thanks a bunch!

May 28th, 2015 8:53pm

Hi,

Per my understanding you might want to open the display form in a dialog when user clicks an item in a custom gridview.

From the code provided, when user clicks the item in the gridview, the user will be redirected to the display form page(not in a dialog), plus with the script in the display form page, seems a dialog will popup. Apparently, this is not what you really expected.

A suggestion is that you can inject the custom JavaScript code(with the SP.UI.ModalDialog.ShowPopupDialog(url) Method) into the NavigateUrl property of the HyperlinkField control:

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.navigateurl(v=vs.110).aspx

A code demo in the thread below about how to work with NavigateUrl property for your reference:

http://stackoverflow.com/questions/10537291/how-to-call-javascript-from-asp-net-hyperlink-control

Thanks 

Free Windows Admin Tool Kit Click here and download it now
May 31st, 2015 3:16am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics