UserControl and Properties

Discussion in 'ASP .Net Building Controls' started by Zürcher See, Apr 15, 2004.

  1. Zürcher See

    Zürcher See Guest

    Who can explain me why this very simple UserControl with the "Document"
    property, when is in a WebForm, I can't see/set the "Document" property from
    the Properties Frame of VisualStudio?


    <%@ Control Language="c#" AutoEventWireup="false"
    <asp:Label id="Label1" runat="server">Label</asp:Label>

    sing System;

    using System.Data;

    using System.Drawing;

    using System.Web;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.HtmlControls;

    using System.ComponentModel;

    namespace WebApplication1


    /// <summary>

    /// Summary description for WebUserControl1.

    /// </summary>

    public class WebUserControl1 : System.Web.UI.UserControl


    protected System.Web.UI.WebControls.Label Label1;

    private string _document;

    private void Page_Load(object sender, System.EventArgs e)


    // Put user code to initialize the page here




    public string Document


    get{if (this._document!=null) return this._document; else return "";}



    #region Web Form Designer generated code

    override protected void OnInit(EventArgs e)



    // CODEGEN: This call is required by the ASP.NET Web Form Designer.





    /// <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);




    Zürcher See, Apr 15, 2004
    1. Advertisements

  2. The reason is because Visual Studio .NET has poor designer support for
    User Controls. What you should experience with your User Control,
    though, is that the Document property can be accessed in the page's
    Code-Behind class via IntelliSense.

    For a thorough examination of User Controls, check out my article:

    An Extensive Examination of User Controls

    Happy Programming!


    Scott Mitchell

    * When you think ASP, think!
    Scott Mitchell [MVP], Apr 15, 2004
    1. Advertisements

  3. Zürcher See

    Zürcher See Guest

    Yes, I know that, I was used to write UserControl for WebForm where there
    wasn't such problems.
    Zürcher See, Apr 15, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.