Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Only content controls are allowed directly in a content page.

Status
Not open for further replies.

technisup

Programmer
Sep 28, 2007
41
US
Hello, from my research i noticed that i have something wrong with my masterpage, because when i try to do something like:


Response.Write("<script language=Javascript>alert('Elr')</script>")

It highlight the code and when i do a rollover the text diaplays:

"Path file\Ciudad.aspx": ASP.Net runtime error: Only Content Controls are allowed directly in a Content Page that contains content controls.

This is the masterpage code:

<%@ Master Language="VB" %>


<script runat="server">

</script>

<html xmlns=" >
<head runat="server">
<link href="StyleSheet.css" rel="Stylesheet" type="text/css" />
<title>Untitled Page</title>
</head>
<body class="twoColFixLtHdr">

<div id="container">
<div id="header">
<h1>
<img src="Images/Titlebar.png" /></h1>
</div>
<div id="sidebar1">



<p>
<img src="Images/Sidebar.png" style="position: relative" />&nbsp;</p>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<!-- end #sidebar1 -->

</div>
<form id="form1" runat="server">
<div id="mainContent">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">

<h1> &nbsp;</h1>



<!-- end #mainContent -->
</asp:ContentPlaceHolder></div>
</form>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<div id="footer">
<img src="Images/Footer.png" />

<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>


How can I solve this? Thx
 
use Page.ClientScriptManager.RegisterScript(...) to add the javascript to the page. (or some object along those lines.)

This error occurs because webforms does not want/allow you to directly write html. You must go through the webform's framework to customize the html.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top