• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Get a reference to a LiteralControl from the page's base class

I've got a LiteralControl on my aspx page. The aspx page inherits from a base class (which inherits from System.Web.UI.Page). I want to set the Text property of the LiteralControl from the base class, but how do I get a reference to it? Page.FindControl returns a simple Control, which doesn't have a Text property. Thanks...
0
sumo_the_cat
Asked:
sumo_the_cat
  • 4
  • 3
1 Solution
 
ihenryCommented:
Since a control inside aspx normally declared as protected scope, you should be able to just call the variable name directly inside the inherit class.

LiteralControl1.Text = "this line is in class that inherits the base class"
0
 
sumo_the_catAuthor Commented:
other way round. i need to put this line in the base class!
0
 
ihenryCommented:
This?

Protected WithEvents MyLiteral As System.Web.UI.WebControls.LiteralControl and in page_load or override onload method and assign the LiteralControl text property to a value.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ihenryCommented:

And in aspx page that inherits baseclass drop a literal control but remove its variable declaration.
0
 
sumo_the_catAuthor Commented:
I don't think that works. But I've solved the problem in a different way. Thanks for your help. Peter.
0
 
ihenryCommented:

I can assure you that works, I have exactly the same situation with you :0)
0
 
sumo_the_catAuthor Commented:
Ok, thanks! pete.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now