How can I retrieve the URL of an item/document in a (generic) document library when the only thing I have is the ID, obtained through:
SP.ListOperation.Selection.getSelectedItems();
My intention is to use the obtained URL to open the document through a link, redirect or in a dialog and execute window.print(); onload(Page_Load).
My code for the dialog window is:
function resultCallback(result, value) {
SP.UI.Notify.addNotification('Success!');
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var myItems = '';
myItems = items[0].id;
if (myItems != '') {
var options = {
url: '{SiteUrl}/_layouts/Benetton_FRA/download.aspx?Items=' + myItems + '&ListId={SelectedListId}&Source={Source}',
tite: 'My Page',
allowMaximize: false,
showClose: true,
width: 500,
height: 160,
dialogReturnValueCallback: resultCallback
};
SP.UI.ModalDialog.showModalDialog(options);
}
And the Page_Load part:
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("<script language='javascript'>");
Response.Write("window.print()");
Response.Write("</script>");