473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

trouble setting a property on a custom web control

hi

asp.net 2.0

I have created a custom web control, here is it's header:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %>

In another custom web user control, I use this web control:
<%@ Register Src="~/Controls/EditUserBox.ascx" TagName="Eub" TagPrefix="mb"
%>
<mb:Eub ID="Eub1" runat="server" />
(the <mb:Eub ID="Eub1" runat="server" /is placed inside a
CreateUserWizard)

EditUserBox has a custom property:
private bool _display = true;
public bool Display
{
get { return _display; }
set { _display = value; }
}

Here is the PROBLEM:
this.Eub1.Display = false;
gives me this error:
- 'Controls_CreateUserBox' does not contain a definition for 'Eub1'

any suggestions why this don't work?
Oct 10 '08 #1
4 1810
I have never really used the CreateUserWizard, but I have used templated
controls (You did put the Eub control inside one of the templates, didn't
you?). Try using the FindControl method of the template from the
CreateUserWizard that you put your Eub control in (and obviously do a type
conversion so that you can access it's Display property). If this is unclear
or if you need more help, try sending a little more code so we can see
exactly what you did. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:ec**************@TK2MSFTNGP04.phx.gbl...
hi

asp.net 2.0

I have created a custom web control, here is it's header:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %>

In another custom web user control, I use this web control:
<%@ Register Src="~/Controls/EditUserBox.ascx" TagName="Eub"
TagPrefix="mb" %>
<mb:Eub ID="Eub1" runat="server" />
(the <mb:Eub ID="Eub1" runat="server" /is placed inside a
CreateUserWizard)

EditUserBox has a custom property:
private bool _display = true;
public bool Display
{
get { return _display; }
set { _display = value; }
}

Here is the PROBLEM:
this.Eub1.Display = false;
gives me this error:
- 'Controls_CreateUserBox' does not contain a definition for 'Eub1'

any suggestions why this don't work?

Oct 10 '08 #2
thanks for posting in my thread.

I've just tried using the FindControl, but it didn't work :(
I tried FindControl 3 different ways, and all give NULL:
public partial class Controls_CreateUserBox : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Controls_EditUserBox custom =
(Controls_EditUserBox)this.FindControl("Eub1");
Controls_EditUserBox custom1 =
(Controls_EditUserBox)CreateUserWizardStep1.FindCo ntrol("Eub1");
Controls_EditUserBox custom2 =
(Controls_EditUserBox)cuwNewUser.FindControl("Eub1 ");
}
}

Here is the code of CreateUserWizard:
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"
Title="Initial step">
<ContentTemplate>

<div style="margin-left:auto; margin-right:auto; width:400px;
border:solid 2px black; background-color:#eeddcc; position:relative;">
<div class="sectiontitle" style="text-align:center;">Opprett ny bruker</div>
<asp:Table ID="tblEditUser" runat="server" Width="100%" BorderWidth="1"
BorderColor="Black">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right"
Width="120">Brukernavn:</asp:TableCell>
<asp:TableCell Width="240" ><asp:TextBox ID="UserName"
runat="server" Width="100%"></asp:TextBox></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireUserName"
runat="server"
ErrorMessage="Username is required"
ControlToValidate="UserName"
SetFocusOnError="false" Display="Dynamic"
ValidationGroup="cuwNewUser">*
</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Passord:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Password" TextMode="Password"
runat="server" Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Bekreft
Passord:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="ConfirmPassword"
TextMode="Password" runat="server"
Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">E-post:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Email" runat="server"
Width="100%"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Spørsmål:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Question" runat="server"
Width="100%"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Svar:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Answer" runat="server"
Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>
</asp:Table>
<mb:Eub ID="Eub1" runat="server" />
<asp:ValidationSummary ID="ValidationSummary1"
ValidationGroup="cuwNewUser"
ShowSummary="false"
ShowMessageBox="false"
runat="server" />
</div>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"
Title="Completed">
<ContentTemplate>
<div class="sectiontitle">Success</div>
A confirmation email is being sent to you.<br />
This email contain a link you need to click on to
activate your profile <br />
To continue click <asp:HyperLink ID="hlRedirect"
runat="server" NavigateUrl="~/Admin/ManageUsers.aspx">here</asp:HyperLink>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>

************************************************** ****
Here is some code from the custom web control which is used the above code:
public partial class Controls_EditUserBox : System.Web.UI.UserControl
{
private bool _display = true;
public bool Display
{
get { return _display; }
set { _display = value; }
}

************************************************** ******
Here is the first tag in the control that uses the custom control:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="CreateUserBox.ascx.cs" Inherits="Controls_CreateUserBox" %>
<%@ Register Src="~/Controls/EditUserBox.ascx" TagName="Eub" TagPrefix="mb"
%>

************************************************
This webcontrol I have trouble accessing is placed on another custom web
control.

The purpose of the display property is that the web control contains a row I
sometimes want to hide.

any suggestions?
Oct 10 '08 #3
Sorry, I left one part out in my response. Use the FindControl method of the
ContentTemplate.Controls property of the CreateUserWizardStep. It's been a
little while since I've done what you're doing, but I know it involves the
ContentTemplate or ContentTemplateContainer (I think ContentTemplate) and
Controls properties, so fool around with those, and I think you'll be able
to get there. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:Ot**************@TK2MSFTNGP02.phx.gbl...
thanks for posting in my thread.

I've just tried using the FindControl, but it didn't work :(
I tried FindControl 3 different ways, and all give NULL:
public partial class Controls_CreateUserBox : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Controls_EditUserBox custom =
(Controls_EditUserBox)this.FindControl("Eub1");
Controls_EditUserBox custom1 =
(Controls_EditUserBox)CreateUserWizardStep1.FindCo ntrol("Eub1");
Controls_EditUserBox custom2 =
(Controls_EditUserBox)cuwNewUser.FindControl("Eub1 ");
}
}

Here is the code of CreateUserWizard:
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"
Title="Initial step">
<ContentTemplate>

<div style="margin-left:auto; margin-right:auto; width:400px;
border:solid 2px black; background-color:#eeddcc; position:relative;">
<div class="sectiontitle" style="text-align:center;">Opprett ny
bruker</div>
<asp:Table ID="tblEditUser" runat="server" Width="100%" BorderWidth="1"
BorderColor="Black">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right"
Width="120">Brukernavn:</asp:TableCell>
<asp:TableCell Width="240" ><asp:TextBox ID="UserName"
runat="server" Width="100%"></asp:TextBox></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireUserName"
runat="server"
ErrorMessage="Username is required"
ControlToValidate="UserName"
SetFocusOnError="false" Display="Dynamic"
ValidationGroup="cuwNewUser">*
</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Passord:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Password" TextMode="Password"
runat="server" Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Bekreft
Passord:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="ConfirmPassword"
TextMode="Password" runat="server"
Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">E-post:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Email" runat="server"
Width="100%"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell
HorizontalAlign="Right">Spørsmål:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Question" runat="server"
Width="100%"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Svar:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Answer" runat="server"
Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>
</asp:Table>
<mb:Eub ID="Eub1" runat="server" />
<asp:ValidationSummary ID="ValidationSummary1"
ValidationGroup="cuwNewUser"
ShowSummary="false"
ShowMessageBox="false"
runat="server" />
</div>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"
Title="Completed">
<ContentTemplate>
<div class="sectiontitle">Success</div>
A confirmation email is being sent to you.<br />
This email contain a link you need to click on to
activate your profile <br />
To continue click <asp:HyperLink ID="hlRedirect"
runat="server" NavigateUrl="~/Admin/ManageUsers.aspx">here</asp:HyperLink>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>

************************************************** ****
Here is some code from the custom web control which is used the above
code:
public partial class Controls_EditUserBox : System.Web.UI.UserControl
{
private bool _display = true;
public bool Display
{
get { return _display; }
set { _display = value; }
}

************************************************** ******
Here is the first tag in the control that uses the custom control:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="CreateUserBox.ascx.cs" Inherits="Controls_CreateUserBox" %>
<%@ Register Src="~/Controls/EditUserBox.ascx" TagName="Eub"
TagPrefix="mb" %>

************************************************
This webcontrol I have trouble accessing is placed on another custom web
control.

The purpose of the display property is that the web control contains a row
I sometimes want to hide.

any suggestions?

Oct 10 '08 #4
it was the ContentTemplateContainer, problem is solved ;)
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:O9**************@TK2MSFTNGP02.phx.gbl...
Sorry, I left one part out in my response. Use the FindControl method of
the ContentTemplate.Controls property of the CreateUserWizardStep. It's
been a little while since I've done what you're doing, but I know it
involves the ContentTemplate or ContentTemplateContainer (I think
ContentTemplate) and Controls properties, so fool around with those, and I
think you'll be able to get there. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:Ot**************@TK2MSFTNGP02.phx.gbl...
>thanks for posting in my thread.

I've just tried using the FindControl, but it didn't work :(
I tried FindControl 3 different ways, and all give NULL:
public partial class Controls_CreateUserBox : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Controls_EditUserBox custom =
(Controls_EditUserBox)this.FindControl("Eub1");
Controls_EditUserBox custom1 =
(Controls_EditUserBox)CreateUserWizardStep1.FindC ontrol("Eub1");
Controls_EditUserBox custom2 =
(Controls_EditUserBox)cuwNewUser.FindControl("Eub 1");
}
}

Here is the code of CreateUserWizard:
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1"
runat="server" Title="Initial step">
<ContentTemplate>

<div style="margin-left:auto; margin-right:auto; width:400px;
border:solid 2px black; background-color:#eeddcc; position:relative;">
<div class="sectiontitle" style="text-align:center;">Opprett ny
bruker</div>
<asp:Table ID="tblEditUser" runat="server" Width="100%" BorderWidth="1"
BorderColor="Black">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right"
Width="120">Brukernavn:</asp:TableCell>
<asp:TableCell Width="240" ><asp:TextBox ID="UserName"
runat="server" Width="100%"></asp:TextBox></asp:TableCell>
<asp:TableCell>
<asp:RequiredFieldValidator ID="valRequireUserName"
runat="server"
ErrorMessage="Username is required"
ControlToValidate="UserName"
SetFocusOnError="false" Display="Dynamic"
ValidationGroup="cuwNewUser">*
</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell
HorizontalAlign="Right">Passord:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Password" TextMode="Password"
runat="server" Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Bekreft
Passord:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="ConfirmPassword"
TextMode="Password" runat="server"
Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">E-post:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Email" runat="server"
Width="100%"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell
HorizontalAlign="Right">Spørsmål:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Question" runat="server"
Width="100%"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>

<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">Svar:</asp:TableCell>
<asp:TableCell><asp:TextBox ID="Answer" runat="server"
Width="100%"></asp:TextBox></asp:TableCell>
</asp:TableRow>
</asp:Table>
<mb:Eub ID="Eub1" runat="server" />
<asp:ValidationSummary ID="ValidationSummary1"
ValidationGroup="cuwNewUser"
ShowSummary="false"
ShowMessageBox="false"
runat="server" />
</div>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"
Title="Completed">
<ContentTemplate>
<div class="sectiontitle">Success</div>
A confirmation email is being sent to you.<br />
This email contain a link you need to click on to
activate your profile <br />
To continue click <asp:HyperLink ID="hlRedirect"
runat="server"
NavigateUrl="~/Admin/ManageUsers.aspx">here</asp:HyperLink>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>

************************************************* *****
Here is some code from the custom web control which is used the above
code:
public partial class Controls_EditUserBox : System.Web.UI.UserControl
{
private bool _display = true;
public bool Display
{
get { return _display; }
set { _display = value; }
}

************************************************* *******
Here is the first tag in the control that uses the custom control:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="CreateUserBox.ascx.cs" Inherits="Controls_CreateUserBox" %>
<%@ Register Src="~/Controls/EditUserBox.ascx" TagName="Eub"
TagPrefix="mb" %>

*********************************************** *
This webcontrol I have trouble accessing is placed on another custom web
control.

The purpose of the display property is that the web control contains a
row I sometimes want to hide.

any suggestions?


Oct 10 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jason Butera | last post by:
I know that I can read/write custom properties of an object by using the following: Setting: document.all.customProp = "this"; Getting: document.all.customProp; Is there a way I can run...
4
by: Earl Teigrob | last post by:
I have a property set in my templated custom control as follows public System.Drawing.Color tableColor; public System.Drawing.Color TableColor { set { tableColor = value; } get
9
by: james.e.coleman | last post by:
Hello, I have created a custom dropdownlist that is used multiple times within a single page. When trying to set the values of the controls with the page in which they are being used, they all...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
1
by: Demi | last post by:
I want to be able to define standard colors in a base form, then have child forms use those values instead of standard colors. Ex in my base form I want to do this: Color myColor =...
4
by: Rico | last post by:
Hello, I have an MDE application where I use a bound object frame to display an image. This frame is updatable and bested on the contents of an OLE field. My problem is, some images display as...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.