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

  • Home
  • SEARCH
  • 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 290453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:59:57+00:00 2026-05-12T05:59:57+00:00

I want to wrap up a chunk of HTML render logic in a User

  • 0

I want to wrap up a chunk of HTML render logic in a User Control. Then I want to pass a custom product object (title, thumbnail, id, etc.) to the UserControl that it can use when it renders. Ideally I want to use this in a repeater (or for loop) and pass the current custom product object into the UC.

Every example I’ve seen has been passing through strings on the UC tag but thats not really want I want to do as it means I’ll have references everywhere that need updating should we add a new field that needs rendering.

Any ideas?

.Net 1 using VB.net (not my first choice for .net so go easy)

HTML example to get us going, this would be in the .ascx page:

<div>
  <h3><%= myProd.title %></h3>
  <img src="<%= myProd.thumbnail %>" />
  <p>
    <%= myProd.description %>
  </p>
</div>

UPDATE:

Ok so with some hacking around here is what I’ve come up with, its not working though, whats the missing piece of this puzzle?

Create a UserControl and add this to the code behind:

Public Class ProductRender
    Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Private _product As productItem 

    Public Property myProd() As productItem 
        Get
            myProd = Me._product
        End Get
        Set(ByVal Value As productItem )
            Me._product = Value
        End Set
    End Property
End Class

In the UC ascx page I simply have the html above.

In the page that uses the UC I simply added the following for testing:

...usual ascx header stuff...
<%@ Register TagPrefix="ORC" TagName="productRender" Src="productRender.ascx" %>
<ORC:productRender id="Assetrender1" runat="server" asset="<%# getDummyProduct() %>" />

in the code behind I declare getDummyProduct as so:

Public Function getDummyProduct() As productItem
    getDummyProduct = New productItem( "DVD Player", "It plays DVDs!", "some_thumb.jpg", 30 )
End Function

Yet in my ascs page I get:”Object reference not set to an instance of an object”

Line 1:  <%@ Control Language="vb" AutoEventWireup="false" Codebehind="ProductRender.ascx.vb" Inherits="MyApp.ProductRender" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
Line 2:  <h3>
Line 3:  <%= myProd.title %>
Line 4:  </h3>
  • 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-12T05:59:57+00:00Added an answer on May 12, 2026 at 5:59 am

    Slaps forehead

    Need to call DataBind in Page.OnLoad for the databinding to work, that explains why I was getting Object not found!

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

Sidebar

Related Questions

Some words pass from search, I want to wrap them with a div then
I want to be able to include a dynamic chunk of HTML in a
I want to wrap some html elements for gmail address in a given string.
Im building a custom generator for my app where I basically want to wrap
I want to wrap part of the TinyXML library in some custom classes in
I want to wrap a piece of code that uses the Windows Impersonation API
I want to wrap a Perl one-liner in a batch file. For a (trivial)
in a project we want to wrap the Boost Asio socket in a way,
I've got a (poorly written) base class that I want to wrap in a
Should I wrap all the files I want to install in individual components? What

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.