Custom Server Control raising events for nested controls

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top