This example shows how to load a file when a user clicks a custom command button in the Grid.
When a user clicks a button, the file with the corresponding Employee ID, is added to the window.location.href
property as a parameter. On the server side, the file with the specified name is sent to the client in response.
protected void Page_Load(object sender, EventArgs e) {
if (Request["ID"] != null)
SendFile(Request["ID"]);
// ...
This example demonstrates how to specify the uploaded file name in two ways:
- Specify the name on the client.
- Send a callback to get the name from the server.
For demonstration purposes, in both approaches it is prohibited to download the 9.png file.
Handle the CustomButtonClick event to set the window.location.href
property.
function DoClientRedirect(value) {
window.location.href = 'Default.aspx?ID=' + value;
}
Add the ASPxCallback control to your application and call the PerformCallback method to sends a callback to the server.
function DoCallbackRedirect(value) {
callback.PerformCallback(value);
}
The method invokes the server Callback event. Handle the event to specify the name of the downloaded file and send the result to the client CallbackComplete event.
protected void ASPxCallback1_Callback(object source, CallbackEventArgs e) {
e.Result = string.Format("Default.aspx?ID={0}", e.Parameter);
}
Handle the CallbackComplete
event to set the window.location.href
property.
function OnCallbackComplete(s, e) {
window.location.href = e.result;
}