title: Hiding video when src is not found
body: <p>I have a video that retrieves its src from a database. The video tag is placed inside a repeater which is bound to the database. I want to hide the video if the src is not found (so it is not in DB). I tried to use Javascript for this but it's not working. </p>
  
  <p>Here is the code of the video element inside the repeater: </p>
  
  <pre><code>&lt;video controls="true" id="pVideo"&gt;
                              &lt;source  src='&lt;%# !String.IsNullOrEmpty(Eval("postVideo2").ToString()) ? "/uploadedVideos/" + Eval("postVideo2"): "" %&gt;' type="video/mp4"/&gt; 
  
                          &lt;/video&gt;
  </code></pre>
  
  <p>This is the Javascript section in the head element: </p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
          var v = document.getElementById("pVideo");
          v.error = function () {
              this.style.display = "none";
          }
  
      &lt;/script&gt;
  </code></pre>
  
  <p>This doesn't work, if there is a video it displays it well, but if there is no video I got a gray box instead saying "no video with supported format and MIME type found" this happens because the src will be empty, but I want to hide this. </p>
  
  <p>Can anyone please tell me how to solve this problem? </p>
  
  <p>Thanks. </p>