.Net User Control - Why Not Working?? Options
Gregorius
Posted: Tuesday, May 08, 2007 10:56:52 AM

Rank: Addict

Joined: 7/29/2006
Posts: 513
Location: Sydney, Australia
This is driving me nutty... I've got a simple hello world user control, with a label on the ascx page.

When i insert the macro into the RTE, it actually renders correctly, sending the macro parameter value to the label... but when i view the actual page from the front end, it doesnt execute any of the code-behind stuff.

This has really got me stumped... any suggestions as to what i might be doing wrong?

Code is as follows:

Code:

namespace HelloWorldUmbracoWebApp
{
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    /// <summary>
    ///        Summary description for WebUserControl1.
    /// </summary>
    public class TestWebUserControl : System.Web.UI.UserControl
    {
      private string m_MessageText;
        protected System.Web.UI.WebControls.Label myLabel;
        protected System.Web.UI.WebControls.Label myLabel2;

      protected System.Web.UI.WebControls.Literal mainLiteral;

        private void Page_Load(object sender, System.EventArgs e)
        {
            myLabel.Text = "Hello i'm a label";
            myLabel2.Text = m_MessageText;
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }
        
        /// <summary>
        ///        Required method for Designer support - do not modify
        ///        the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

      public string MessageText
      {
         set
         {
            m_MessageText = value;
         }
      }

    }
}


And the ascx page:
Code:

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="HelloWorldUmbracoWebApp.ascx.cs" Inherits="HelloWorldUmbracoWebApp.TestWebUserControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<div>
    Hello World!
    <br>
    <asp:Label ID="myLabel" Runat="server"></asp:Label>
    <asp:Label Id="myLabel2" Runat="server"></asp:Label>
</div>


All i see on the front-end is "Hello World", with no errors

In the umbraco admin RTE, where i inserted the Macro, it renders the following:
Hello World!
Hello i'm a label Control Text from Macro

Hoping somebody can help .. i'm sure its somethign simple, just i cant see it. :|

thanks all
greg
Gregorius
Posted: Tuesday, May 08, 2007 10:58:59 AM

Rank: Addict

Joined: 7/29/2006
Posts: 513
Location: Sydney, Australia
And here's an abridged version of the HTML Output on the frontend:
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
....
   </head>
   <body>
      <form name="_ctl5" method="post" action="/temp.aspx" id="_ctl5">
<input type="hidden" name="__VIEWSTATE" value="dDwtODEyNDAyNDg3Ozs+rHtxDX7XOSma/k1+DnjJL+kyT4Q=" />
            
         <div id="main">
           
<div>
    Hello World!
    <br>
    <span id="HelloWorldUmbracoWebApp10_myLabel"></span>
    <span id="HelloWorldUmbracoWebApp10_myLabel2"></span>
</div>



         </div>    
      </form>
   </body>
</html>



Gregorius
Posted: Tuesday, May 08, 2007 11:10:58 AM

Rank: Addict

Joined: 7/29/2006
Posts: 513
Location: Sydney, Australia
HAHA... amazing how the minute i post a request, i solve the problem. Turns out it was a template issue... we're using a special master macro to obtain some advanced functionality, and it was this that was messing with the .Net control... but aaalllllll gooooooood noooooowwwwwwwww :)
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.