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 6941159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:50:58+00:00 2026-05-27T12:50:58+00:00

I have constructed an ASP.NET user control Box.ascx wtih the following code. <div id=divContent

  • 0

I have constructed an ASP.NET user control “Box.ascx” wtih the following code.

<div id="divContent" runat="server" visible='<%# AllowedToView(this.Privacy) %>'>
    Content
</div>

In the codebehind, “Box.ascx.cs” has the following code.

public string Privacy = string.Empty;
public bool AllowedToView(string privacy)
{
    return true;
}

When I use this control in a repeater, AllowedToView() function is hit. If I use this control without a repeater, AllowedToView() function isn’t called. I want to know why this weird situation happens and how can I make the control call the AllowedToView() function when used without repeater.

Details are below.

I use this control in a repeater in “Default.aspx”.

<asp:Repeater ID="rpRecords" runat="server">
    <ItemTemplate>
        <uc1:Box ID="myBox" runat="server" RecordID = '<%# Eval("RecordID") %>' />
    </ItemTemplate>
</asp:Repeater>

The repeater is databound in “Default.aspx.cs” with the following code:

DataTable dt = FillTable();
rpRecords.DataSource = dt;
rpRecords.DataBind();

I use the “Box.ascx” control in “ShowBox.aspx” with the following code.

<body>
    <uc1:Box ID="myBox" runat="server" />
</body>

I give values to the user control from the codebehind with the following code.

protected void Page_Load(object sender, EventArgs e)
{
    myBox.RecordID = "1";
}
  • 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-27T12:50:59+00:00Added an answer on May 27, 2026 at 12:50 pm

    As mentioned in another answer, the # means it will require databinding to be executed.

    So to answer your question “How to make it run outside of the repeater” the simple answer is to call myBox.DataBind().

    Your question is very similar to asp.net inline code <%# MyboolVal %>. The problem is that <%= is equal to Response.Write and outputs straight HTML, so it won’t work when setting the visible property.

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

Sidebar

Related Questions

I have a simple ASP.NET Web User Control. It looks like this: <%@ Control
In ASP.net, I have the following code. I'm making a website in JSP and
Say I have a User Control in ASP.NET that contains a button: public class
I have an ASP.NET MVC 2 application which in part allows a user to
I have an asp.net application with c# code-behind. This application is a dispatch system
I have an asp.net mvc application, which uses the default user database. It all
I am attempting to write a 'User Control' in WinForms .NET (not ASP.NET). The
I have a ASP.NET GridView that uses template columns and user controls to allow
Scenario : I have a complex Asp.net app serving various units through programmatically constructed
I have an Asp.NET 3.5 application with security/authentication. I have a second application (built

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.