[thelist] .NET: Public variable set in user control
Casey Crookston
caseyc at IntelliSoftmn.com
Tue Oct 10 12:44:09 CDT 2006
Ok, according to page 260 of ASP.NET Unleashed (1.1), "All public
variables declared in the user control file are exposed as properties of
the user control." So I have a user control called navigation.ascx. In
navigation.ascx.vb I declare a public variable called ImageToDisplay as
a string. Then, in the page that is referring to the user control, I
need to programmatically set the value of this string. In the HTML we
declare the control as such:
<%@ Page CodeBehind="default.aspx.vb" Language="vb"
AutoEventWireup="false" Inherits="intellisoft._default" %>
And then later:
<uc1:navigation id="Navigation1" runat="server" />
Although it does work to do this:
<uc1:navigation id="Navigation1" ImageToDisplay="valueHere"
runat="server" />
I need to set the value programmatically. This in the code-behind
Navigation1.ImageToDisplay = "valueHere"
returns this error:
'ImageToDisplay' is not a member of 'System.Web.UI.UserControl'.
As far as I can tell, I'm doing this exactly as the example in the book.
What else do I need to do?
Thanks,
Casey
More information about the thelist
mailing list