It seems like I'm overlooking something quite straightforward.
I am creating binary files that I am associating with a GridView.
FileDownloadGrid.DataSource = downloadList;
FileDownloadGrid.DataBind();
The part of the grid that interests me is written in the following way:
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="DownloadFile" runat="server" Text="Download" CommandName="DownloadFile1"
CommandArgument='<%#Eval("FullName") +"|" + Eval("Name") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
I am trying to implement the IFRAME Ajax approach for downloading the file.
function InitializeRequest(sender, args) {
// Ensure that this async postback is actually
// requesting the file download.
if (sender._postBackSettings.sourceElement.id == "FileDownloadGrid") {
// Create an IFRAME.
var iframe = document.createElement("iframe");
// Get the desired region from the dropdown.
var fName = $get("CommandArgument").value;
// Point the IFRAME to GenerateFile, with the
// desired region as a querystring argument.
iframe.src = "Default2.aspx?fName=" + fName;
// This makes the IFRAME invisible to the user.
iframe.style.display = "none";
// Add the IFRAME to the page. This will trigger
// a request to GenerateFile now.
document.body.appendChild(iframe);
}
}
Based on my research, it seems like I cannot access the CommandArgument on the client side, and I am struggling to figure out how to obtain the 'FullName' in the script.
Could someone please guide me in the right direction? I am getting quite frustrated with something that should be relatively straightforward.
Thank you
Gene