title: Can't pass a variable to a user control
body: <p>I am using the below example code and have a problem where I can't pass the Request.RawUrl value into an object that extends the Control object (class Test below).</p>
  
  <p>When I use the line:</p>
  
  <pre><code>&lt;Test1:Test runat="server" ID="testControl" Target="&lt;%# Request.RawUrl %&gt;"&gt;&lt;/Test1:Test&gt;
  </code></pre>
  
  <p>I find that the Target property is never called.</p>
  
  <p>If I use this line instead:</p>
  
  <pre><code>&lt;Test1:Test runat="server" ID="testControl" Target="&lt;%# Request.RawUrl %&gt; test"&gt;&lt;/Test1:Test&gt;
  </code></pre>
  
  <p>the string value <code>"&lt;%# Request.RawUrl %&gt; test"</code> is passed to the Target property.</p>
  
  <p>If I use this line as explained in many posts online:</p>
  
  <pre><code>&lt;Test1:Test runat="server" ID="testControl" Target="&lt;%= Request.RawUrl %&gt;"&gt;&lt;/Test1:Test&gt;
  </code></pre>
  
  <p>the string value <code>"&lt;%= Request.RawUrl %&gt;"</code> is passed to the Target property.</p>
  
  <p>I need to get the value of Request.RawUrl passed to the Target Property of my Test control object. Does anyone have any ideas where I am going wrong?</p>
  
  <hr>
  
  <p>Control:</p>
  
  <pre><code>namespace Testing
  {
      public class Test : Control
      {
          public Test()
          {
  
          }
  
          private string target;
  
          public string Target
          {
              get { return target; }
              set { target = value; }
          }
      }
  }
  </code></pre>
  
  <p>User Control:</p>
  
  <pre><code>&lt;%@ Control Language="C#" Debug="true" %&gt;
  &lt;%@ Register TagPrefix="Test1" Assembly="Test" Namespace="Testing" %&gt;
  
  &lt;Test1:Test runat="server" ID="testControl" Target="&lt;%# Request.RawUrl %&gt;"&gt;&lt;/Test1:Test&gt;
  </code></pre>