title: Get value from my own web control
body: <p>I write one example to create own control on ASP.NET Froms. The controls very simple- combobox and button. User need choose value and when after he submit the button, the value from combobox need display in label.
  So. Code of my Control:</p>
  
  <pre><code>public class MyControl:Control,IPostBackEventHandler
  {
      protected override void Render(HtmlTextWriter writer)
      {
          writer.AddAttribute("size","1");
          writer.AddAttribute("ID","List2");
          writer.AddAttribute("name", "ListYear");
          writer.RenderBeginTag(HtmlTextWriterTag.Select);
  
          for (int i = 1950; i &lt; DateTime.Now.Year; i++)
          {
              writer.RenderBeginTag(HtmlTextWriterTag.Option);
              writer.WriteEncodedText(i.ToString());
              writer.RenderEndTag();
          }
  
          writer.RenderEndTag();
  
          writer.AddAttribute("type","submit");
          writer.AddAttribute("value","ClickMe");
          writer.AddAttribute("name","BtnChange");
          writer.RenderBeginTag(HtmlTextWriterTag.Input);
          writer.RenderEndTag();
  
          base.Render(writer);
      }
  
      public delegate void OnClickEventHandler(object sender, EventArgs args);
  
      public event OnClickEventHandler Click;
  
      public void RaisePostBackEvent(string eventArgument)
      {
          Click(this, new EventArgs());
      }
  }
  </code></pre>
  
  <p>The Page ASP:</p>
  
  <pre><code>    &lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestMyControl.aspx.cs" Inherits="Hello.TestMyControl" %&gt;
  &lt;%@ Register assembly="Hello" namespace="Hello" tagPrefix="MyContrl" %&gt;
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:Label ID="Label1" runat="server" Text="Label" Visible="False"&gt;&lt;/asp:Label&gt;
          &lt;br /&gt;
      &lt;MyContrl:MyControl runat="server" OnClick="Unnamed1_OnClick" ID="Control1"&gt;&lt;/MyContrl:MyControl&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And in the end Event function:</p>
  
  <pre><code>protected void Unnamed1_OnClick(object sender, EventArgs args)
      {
          Label1.Visible = true;
          Label1.Text="You choose "+Control1.????+" year";
      }
  </code></pre>
  
  <p>What substitute for a question mark that take the value from the list?</p>
  
  <p>P.S. Something strange is going on. Because when I click the button, the handler is not called, and I can not get into Unnamed1_OnClick</p>