Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7308243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:31:50+00:00 2026-05-28T23:31:50+00:00

Issue: I have a markup like this (only the important lines): <%@ Control Language=C#

  • 0

Issue:
I have a markup like this (only the important lines):

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RTDeluxe.ascx.cs"
Inherits="MainSolution.CONTROLTEMPLATES.Kunde.RTDeluxe" %>
<ul id="linkUl" class="teaserLinksUL" runat="server"/>

The code-behind:

namespace MainSolution.CONTROLTEMPLATES.Kunde
public partial class RTDeluxe : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        linkUl.InnerHtml = string.Empty;
    }
}

I can access the ul inside the code-behind and get no compilation error. But, when I debug the code I get a NullReferenceException because linkUl is NULL.

First I thought that the namespaces are the reason. But, after several tries, I’m sure that they’re correct. The FileLocation seems to be correct and the controltemplates folder of my iis has a “Kunde” folder with the corresponding ascx files in it.

I have other .ascx files with the same structure -> they’re working like a charm.

Question:
Are there any other reasons than the namespace for such behaviour? Do you have any hints where I can look at?

Edit:
The RTDeluxe.ascx.designer.cs file exists, the generated linkUl looks like this:

protected global::System.Web.UI.HtmlControls.HtmlGenericControl linkUl;

Edit2:
Ok, I will try to answer all your questions. Thanks for your time and feedback!

  1. I have restarted Visual Studio -> The Problem persists.
  2. I also have cleaned up the solution and deployed a new one. -> The problem persists.
  3. When I debug and check the control hierachy I can see that the label is NOT there.
  4. When I change the ID the compiler throws an error in the code-behind (which is right). If i change the ID there two I get the same behavoiur as before.
  5. I also restarted my IIS and the whole pc -> No changes.
  6. I have added a Name attribute to the linkul-definition -> No changes.
  7. When I try to use FindControl it returns NULL.
  8. The target-framework is .NET 3.5
  9. The linkul is NOT inside a repeater or any other controls.
  10. Removing/changing the web.config does also not lead to a solution.
  11. Adding EnsureChildControls before accessing the linkUl doesnt change anything.
  12. Moving the code into Page_PreRender does also not work.

I will try out your suggestions not listed here and add them soon.

Edit3:
Here the full markup:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RTDeluxe.ascx.cs" Inherits="MainSolution.CONTROLTEMPLATES.Kunde.RTDeluxe" %>

<ul id="linkUl" class="teaserLinksUL" runat="server"/>

*Edit4:
Ok here some additional info I found out:
When I change something in the markup, like adding plain html text it’s NOT recognized by or shown in the browser. When i do something like this:

   Label label1 = new Label();
   label1.Text = "hugo lives!";
   Controls.Add(label1);

It is shown. It seems like in visual studio everything is fine… But “live” at the server the code-behind speaks to some weird different markup…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:31:51+00:00Added an answer on May 28, 2026 at 11:31 pm

    This might help You a bit:

    On the code-behind file of the user-control at class level, add this code:

    protected global::System.Web.UI.HtmlControls.HtmlGenericControl linkUl = new System.Web.UI.HtmlControls.HtmlGenericControl();
    

    and remove the protected global::System.Web.UI.HtmlControls.HtmlGenericControl linkUl; from RTDeluxe.ascx.designer.cs file

    It might be because its Object was just declared not created.
    Hope this helps..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a markup like this: <label>First Name: <input type=text /></label> <label>Last Name: <input
Here's the issue: I have 2 data contexts that I would like to do
A common issue I have is getting confused what $(this) is referring to. I
This would be my issue I have a drop down that's not displaying fully.
On an Aspx page, I have this markup (setup for a jQuery UI dialog):
Wondering if anyone has a work around for this issue. I've got a markup
I have a <ul> tag that is hardcoded in my markup: So, something like:
I have a web user control with the following markup <table> <tr> <td> <h1>
If I have HTML like this: <dsometext<f<legit></legit> whatever What regex pattern do I use
I have this markup: <div class=myToggledDiv> <div>content</div> </div> <div style=margin-top: 10px;> content </div> Via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.