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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:48:16+00:00 2026-06-09T15:48:16+00:00

I have a web control that looks like this public class Foo : WebControl

  • 0

I have a web control that looks like this

public class Foo : WebControl
{
  [Bindable(true)]
  [Category("Default")]
  [DefaultValue("")]
  [Localizable(true)]
  public string Bar { get; set; }

  protected override void Render(HtmlTextWriter output)
  {
    output.WriteLine(Bar);
  }
}

I want to put this webcontrol in my aspx page like so:

<cc1:Foo Bar="<%= Fa.La.La %>/otherstuff" runat="server" />

(obviously this code is simplified to show the problem)

In my Render method the variable Fa.La.La is not evaluated. It’s coming in as the raw text “<%= Fa.La.La %>” How do I evaluate it?

I’m not particular how the variables are passed in. If the variables can be evaluated if they are passed in as <%# … %>, that works fine. The point is I have some server-side variables I want evaluated before/while my Render() method is called.

The only thing I can think of is to use a regex to grab the contents of <%= … %> and use reflection or something, but there has to be a more elegant way to do this.

This question is pretty similar to using server variables in a href <%= xx %> with runat=server, but it’s not exactly the same since none of the answers there were useful.

  • 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-06-09T15:48:18+00:00Added an answer on June 9, 2026 at 3:48 pm

    You should have to use binding expression <%# expr %>.

    <cc1:Foo Bar='<%# String.Concat(Fa.La.La,"/otherstuff")%>' runat="server" /> 
    

    and call DataBind() method in code-behind.

    public void page_load()
    {
      DataBind();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net UserControl that looks like this: <%@ Control Language=C# AutoEventWireup=true CodeBehind=WebUserControl1.ascx.cs
I have a simple ASP.NET Web User Control. It looks like this: <%@ Control
i have a web.config file that looks like this: <?xml version=1.0?> <configuration> <system.web> <compilation
I have a very simplistic user control that looks like this: <%@ Control Language=C#
I have an ASP.NET GridView which has columns that look like this: | Foo
I have a repository pattern setup using NHibernate. The base class looks like this:
I have an extremely simple control i'm trying to render which looks like this:
I have a Web User Control that contains a CheckBoxList. MyListControl: <asp:checkboxlist id=chkList runat=server>
I have a simple Web Browser Control that displays a local webpage and that
I have a web role configured with SSL, which has a ReportViewer control that

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.