MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Create Pages  (Mono Support )

Viewed 9150 time(s), 5 post(s) 7/2/2014 3:22:27 AMby Samtg
Samtg

Samtg

7/2/2014 3:22:27 AM
Hi,
     I am trying to create a new page, using WebPartSample, as a template, and I keep getting this error, like when I change codebehind (to one I am creating):

Only Content controls are allowed directly in a content page that contains Content controls.

Also, is there an easier way to create new pages (I've been using the WebPartSample, and have not been able to create one from scratch).  Is there a setting or something I might have changed?

Thanks.
This content has not been rated yet. 
440 Reputation 38 Total posts
khorvat

khorvat

7/2/2014 12:50:21 PM
Hi,

can you please provide us with the error you get (if it defers from the one above) and markup of the page template so we can check if it's valid.

Thanks
This content has not been rated yet. 
15993 Reputation 2214 Total posts
Samtg

Samtg

7/5/2014 10:13:08 PM
Sure, here is the .aspx code:

<%@ Page Language="C#" MasterPageFile="/MonoX/MasterPages/DefaultSmallHeader.master" AutoEventWireup="true" Inherits="MonoSoftware.MonoX.Samples.WebPartSample" Title="Web part sample" Codebehind="FamGenSiteQ.aspx.cs" %><br>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %> <br>
<%@ Register TagPrefix="MonoX" TagName="HelloWorld" Src="/MonoX/Samples/WebPartSample/HelloWorld.ascx" %><br>
<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX" TagPrefix="portal" %><br>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %><br>
<asp:Content ID="Content1" ContentPlaceHolderID="cp" Runat="Server"><br>
<table cellspacing="0" cellpadding="0"><br>
<tr><br>
<td class="left-section" style="vertical-align:top;"><br>
<portal:PortalWebPartZoneTableless HeaderText="Left part zone" ID="leftWebPartZone" runat="server" Width="100%" ChromeTemplateFile="LeftColumn.htm" ShowChromeForNonAdmins="true"><br>
<ZoneTemplate><br>
<MonoX:HelloWorld runat="server" ID="helloWorldSample" Title="Hello world" /><br>
</ZoneTemplate><br>
</portal:PortalWebPartZoneTableless><br>
</td><br>
<td class="right-section"><br>

<CKEditor:CKEditorControl ID="CKEditor1" runat="server"<br>
>
</CKEditor:CKEditorControl>          <br>

<portal:PortalWebPartZoneTableless HeaderText="Right part zone" ID="rightPartZone" runat="server" Width="100%" ChromeTemplateFile="RightColumn.htm" ShowChromeForNonAdmins="true" ><br>
<br>
<br>
<ZoneTemplate><br>
<br>
<form id="form" ><br>
Enter your name:<br>
<asp:TextBox id="txt1" runat="server" /><br>
<br>
<input type=text id="webinput" OnClick="submit" Text="Submit"/><br>
<p><asp:Label id="lbl1" runat="server" /></p><br>
</form><br>
<asp:Panel runat="server" ID="pnlDescription"><br>
<p><span class="header_blue">Web part sample</span></p><br>
<p><br>
This is a sample page demonstrating the development and the usage of a very simple Web part. The "Hello word" part on this page contains two custom properties and displays them to the user on a button click. <br>
<br /><br /><br>
Feel free to modify this page during the learning process.<br>
</p><br>
</asp:Panel>          <br>
</ZoneTemplate><br>
</portal:PortalWebPartZoneTableless><br>
</td><br>
</tr><br>
</table><br>
</asp:Content><br>


Here is what the codebehind looks like:

using System;<br>
using System.Data;<br>
using System.Configuration;<br>
using System.Collections;<br>
using System.Web;<br>
using System.Web.Security;<br>
using System.Web.UI;<br>
using System.Web.UI.WebControls;<br>
using System.Web.UI.WebControls.WebParts;<br>
using System.Web.UI.HtmlControls;<br>
using System.Data.SqlClient;<br>
using System.Data.ADO;                  // Database<br>
using System.Globalization;             <br>
<br>
namespace MonoSoftware.MonoX.Samples<br>
{<br>
public partial class FamGenSiteQ : BasePage<br>
<br>
{<br>
<br>
protected void Page_Load(object sender, EventArgs e)<br>
{       <br>
<br>
}<br>
protected void submitButton1_Click(object sender, EventArgs e)<br>
{<br>
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["server=.\SQLEXPRESS;uid=EmailandFamilyWebsiteDatabaseU;pwd=******;database=EmailandFamilyWebsiteDatabase"].ConnectionString);<br>
SqlConnection con = new SqlConnection("server=.\SQLEXPRESS;uid=EmailandFamilyWebsiteDatabaseU;pwd=******;database=EmailandFamilyWebsiteDatabase";);<br>
con.Open();<br>
SqlCommand cmd = new SqlCommand("INSERT INTO Website (Website, Email) VALUES ('" + txt1.Text + "','" + txt2.Text + "')",con);<br>
cmd.ExecuteNonQuery();<br>
con.Close();<br>
}<br>
}  <br>
} <br>
(Ignore <br>'s)

I don't know if I needed that many libraries, but they are there anyway.

Here is the error:
Only Content controls are allowed directly in a content page that contains Content controls.
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseReader(StreamReader reader, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
etc.

-Samtg
This content has not been rated yet. 
440 Reputation 38 Total posts
Samtg

Samtg

7/5/2014 10:08:51 PM
Hi,
     I'm not sure what changed, but the codebehind works now, but I think the error was in when I tried to call a C# function in a button (onClick), that was one error that came up.  Here is another error:

c:\Users\Sam\Documents\My Web
Sites\MonoX5\MonoX_Samples_SourceCode\WebPartSample\FamGenSiteQ.aspx(80):
error CS1061:
'ASP.monox_samples_sourcecode_webpartsample_famgensiteq_aspx' does not
contain a definition for 'submitButton1_Click' and no extension method
'submitButton1_Click' accepting a first argument of type
'ASP.monox_samples_sourcecode_webpartsample_famgensiteq_aspx' could be
found (are you missing a using directive or an assembly reference?)

This happens when there is code like this:
<asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="submitButton1_Click" />
I think I had similar even when I changed it to an html onClick event.
This content has not been rated yet. 
440 Reputation 38 Total posts
khorvat

khorvat

7/9/2014 7:05:09 AM
Your first issue was related to the fact that only WebParts and content controls are allowed to be placed in the WebPartZones. So in order to fix your first issue please make the WebPart with all you controls and then put it in your template page.

Your second issue is related to missing submitButton1_Click in your code behind, but that is related to basic ASP.NET understandings so please take a look at the ASP.NET API documentation.

Let us know if you need anything else.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts