Search code examples
c#asp.netascx

ASP.net basic help with ASCX user control


Trying to build my own user control:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TabMenu.ascx.cs" Inherits="TabMenu" %>

<asp:Panel runat="server" CssClass="tabWrapper">
        <div class="tab tabSelected"><a href="artworkHome.aspx">Home</a></div>
        <div class="tab"><a href="#">Create New</a></div>
        <div class="tab"><a href="#">Help!</a></div>
        <div class="clear"></div>
        <asp:Literal runat="server" ID="lol"></asp:Literal>
</asp:Panel>

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class TabMenu : System.Web.UI.UserControl
{
    public string TabGroup { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {

        if (this.TabGroup == "Artwork")
        {
            lol.Text = "LOL!";
        }

    }
}

This shows fine when used as such:

<CrystalControls:TabMenu runat="server" TabGroup="Artwork" />

Except that "LOL!" isn't showing. I'm probably using properties incorrectly etc, I hope it's clear what I'm trying to do?


Solution

  • I tried your example, but its all working fine, i do get LOL! in the literal. If you debug the code, and set a braekpoint on the check if Tabgroup == "ArtWork", you can check the value of TabGroup, maybe it is not set yet ?