Q: How to dynamically not render a script tag? I want to be able to dynamically (on page load) decide to set it to Visible=false so it won't be rendered. I tried runat=server but that's only for virtual paths.

A: You can use ClientScriptManager.RegisterClientScriptBlock or ClientScriptManager.RegisterStartupScript to conditionally add the script.
if (condition)
{    
    String csname2 = "ButtonClickScript";
    Type cstype = this.GetType();
    StringBuilder cstext2 = new StringBuilder();
    cstext2.Append("<script type=\"text/javascript\"> function DoClick() {");
    cstext2.Append("Form1.Message.value='Text from client script.'} </");
    cstext2.Append("script>");
    cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), false);
}

If you have script that is not small then you can put the script in some js file and use ClientScriptManager.RegisterClientScriptInclude
if (condition)
{
    ClientScriptManager cs = Page.ClientScript;
    cs.RegisterClientScriptInclude("ScriptKey", "ScriptURLToInclude");
}


A: In the ASP.NET markup language you can steer the rendering of any arbitrary contents. That is rendering a script tag only under certain conditions should be as simple as:
<% if (shouldRenderScriptTag) { %>
    <script src="..." />
<% } %>

