By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,474 Members | 3,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,474 IT Pros & Developers. It's quick & easy.

trouble setting a property on a custom web control

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.