<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["k"] == null)
{
pnlSearchResults.Visible = false;
}
else
{
pnlNewsletters.Visible = false;
}
}
</script>
Then you need to modify the application's web.config in the virtual directory folder. Under the SafeMode node, add the following:
<PageParserPaths>
<PageParserPath VirtualPath="/Newsletter/NewsletterSearch.aspx" CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>
Reference:
Code-blocks are not allowed in this file: Using Server-Side Code with SharePoint