The name ‘ZipFile’ does not exist in the current context when including System.IO.Compression

I”m currently running .net version 4.5 and am trying to use it’s “new” zip functions. I’m including System.IO.Compression and am trying to run the following code: using System.IO.Compression; string startPath = @"c:examplestart"; string zipPath = @"c:exampleresult.zip"; string extractPath = @"c:exampleextract"; ZipFile.CreateFromDirectory(startPath, zipPath); ZipFile.ExtractToDirectory(zipPath, extractPath); The issue I’m getting is that The name ‘ZipFile does not … Read more

ASP: runat=server for dynamic control

In the Page_Load method I create a couple of controls, based on various conditions. I would like to register server side code with those controls. However, for the last part I need to declare my controls as server controls. This is normally done by runat=server, but I don’t know how to set this attribute in the C# code. myControl.Attributes.Add(“runat”, “server”) does not do the trick. This one works, meaning that the “test” method is called when I click on it: