D
Dakota2030
I have a custom server control that contains an image button.
______________________________________________________________
protected override void OnLoad(EventArgs e)
{
DownloadButton = new ImageButton();
DownloadButton.ID = "download_file";
DownloadButton.Click += new
System.Web.UI.ImageClickEventHandler(this.DownloadButton_Click);
base.OnLoad (e);
}
protected override void DoRender(HtmlTextWriter output)
{
DownloadButton.RenderControl(output);
//context.Response.Write("THIS IS A TEST");
IWebItem itm = GetItem();
string sTitle = itm.GetFieldValue(TitleField);
}
protected void DownloadButton_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
context.Response.Clear();
context.Response.AddHeader("Content-Disposition", "attachment;
filename=aspuser.dat");
context.Response.ContentType = "application/octet-stream";
context.Response.WriteFile(@"c:\aspuser.dat");
context.Response.End();
}
______________________________________________________________
I want the Downloadbutton_click method to fire when the image button is
clicked. This isn't working the way I currently wrote the control.
The image button is rendered but it will not do a post_back. I must be
missing something or creating the control in the wrong place.
Can anyone provide assistance?
Thanks!
Bryan
______________________________________________________________
protected override void OnLoad(EventArgs e)
{
DownloadButton = new ImageButton();
DownloadButton.ID = "download_file";
DownloadButton.Click += new
System.Web.UI.ImageClickEventHandler(this.DownloadButton_Click);
base.OnLoad (e);
}
protected override void DoRender(HtmlTextWriter output)
{
DownloadButton.RenderControl(output);
//context.Response.Write("THIS IS A TEST");
IWebItem itm = GetItem();
string sTitle = itm.GetFieldValue(TitleField);
}
protected void DownloadButton_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
context.Response.Clear();
context.Response.AddHeader("Content-Disposition", "attachment;
filename=aspuser.dat");
context.Response.ContentType = "application/octet-stream";
context.Response.WriteFile(@"c:\aspuser.dat");
context.Response.End();
}
______________________________________________________________
I want the Downloadbutton_click method to fire when the image button is
clicked. This isn't working the way I currently wrote the control.
The image button is rendered but it will not do a post_back. I must be
missing something or creating the control in the wrong place.
Can anyone provide assistance?
Thanks!
Bryan