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

how to access from code-behind a label into CreateUserWizard control?

P: n/a
Ben
Hi,

i have some problem to access from code-behind a label nested into a
CreateWizard control. I use a html-table for align purpose only.
I try to change the text property of the label with ID="UserNameLabel".

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
<table border="0">
<tr><td>Make a new account</td></tr>
<tr><td><asp:Label ID="UserNameLabel"
runat="server">Username:</asp:Label></td>
<td><asp:TextBox ID="UserName"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired"
runat="server">*</asp:RequiredFieldValidator>
</td></tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
My attempt:
----------
Dim lb As New Label
lb = CreateUserWizard1.WizardSteps.Item(4)
(I also tried with Item(0) till 6).

Thanks for help
Ben
Mar 9 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You might try something like this...

Dim mpUserNameLabel As Label

mpUserNameLabel = CType(usrWelcome.FindControl("UserName"), Label)

If Not mpUserNameLabel Is Nothing Then
mpUserNameLabel.Text = CType(Session("UserName"), String)
End If

usrWelcome is a User Control that I put together that has labels in it.

.... John

"Ben" <bn*@mail.dewrote in message
news:eF****************@TK2MSFTNGP04.phx.gbl...
Hi,

i have some problem to access from code-behind a label nested into a
CreateWizard control. I use a html-table for align purpose only.
I try to change the text property of the label with ID="UserNameLabel".

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
<table border="0">
<tr><td>Make a new account</td></tr>
<tr><td><asp:Label ID="UserNameLabel"
runat="server">Username:</asp:Label></td>
<td><asp:TextBox ID="UserName"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired"
runat="server">*</asp:RequiredFieldValidator>
</td></tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
My attempt:
----------
Dim lb As New Label
lb = CreateUserWizard1.WizardSteps.Item(4)
(I also tried with Item(0) till 6).

Thanks for help
Ben

Mar 9 '07 #2

P: n/a
Ben
Hi John,

it doesn't work.

I tried this:

lb = CType(CreateUserWizard1.FindControl("UserNameLabel "), Label)
lb.Text = "ok"

but i get an error: "Object reference not set to an instance of an object"
.....
"John Kotuby" <jo***@powerlist.comschreef in bericht
news:%2***************@TK2MSFTNGP05.phx.gbl...
You might try something like this...

Dim mpUserNameLabel As Label

mpUserNameLabel = CType(usrWelcome.FindControl("UserName"), Label)

If Not mpUserNameLabel Is Nothing Then
mpUserNameLabel.Text = CType(Session("UserName"), String)
End If

usrWelcome is a User Control that I put together that has labels in it.

... John

"Ben" <bn*@mail.dewrote in message
news:eF****************@TK2MSFTNGP04.phx.gbl...
>Hi,

i have some problem to access from code-behind a label nested into a
CreateWizard control. I use a html-table for align purpose only.
I try to change the text property of the label with ID="UserNameLabel".

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
<table border="0">
<tr><td>Make a new account</td></tr>
<tr><td><asp:Label ID="UserNameLabel"
runat="server">Username:</asp:Label></td>
<td><asp:TextBox ID="UserName"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired"
runat="server">*</asp:RequiredFieldValidator>
</td></tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
My attempt:
----------
Dim lb As New Label
lb = CreateUserWizard1.WizardSteps.Item(4)
(I also tried with Item(0) till 6).

Thanks for help
Ben


Mar 9 '07 #3

P: n/a
And you're sure that the IDof your Wizard Control is 'CreateUserWizard1' and
the ID or your label is 'UserNameLabel'?

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Ben" <bn*@mail.dewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi John,

it doesn't work.

I tried this:

lb = CType(CreateUserWizard1.FindControl("UserNameLabel "), Label)
lb.Text = "ok"

but i get an error: "Object reference not set to an instance of an object"
....
"John Kotuby" <jo***@powerlist.comschreef in bericht
news:%2***************@TK2MSFTNGP05.phx.gbl...
You might try something like this...

Dim mpUserNameLabel As Label

mpUserNameLabel = CType(usrWelcome.FindControl("UserName"), Label)

If Not mpUserNameLabel Is Nothing Then
mpUserNameLabel.Text = CType(Session("UserName"), String)
End If

usrWelcome is a User Control that I put together that has labels in it.

... John

"Ben" <bn*@mail.dewrote in message
news:eF****************@TK2MSFTNGP04.phx.gbl...
Hi,

i have some problem to access from code-behind a label nested into a
CreateWizard control. I use a html-table for align purpose only.
I try to change the text property of the label with ID="UserNameLabel".

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
<table border="0">
<tr><td>Make a new account</td></tr>
<tr><td><asp:Label ID="UserNameLabel"
runat="server">Username:</asp:Label></td>
<td><asp:TextBox ID="UserName"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired"
runat="server">*</asp:RequiredFieldValidator>
</td></tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
My attempt:
----------
Dim lb As New Label
lb = CreateUserWizard1.WizardSteps.Item(4)
(I also tried with Item(0) till 6).

Thanks for help
Ben


Mar 9 '07 #4

P: n/a
Ben
Hi David, thanks for replying.

To be sure, i send you the beginning code as i tested it:

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="findcontrolnested.aspx.vb"
Inherits="login" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server"><br />
<asp:ValidationSummary ID="val" runat="Server" />

<table style="width:690px;">
<tr>
<td valign="top">
<fieldset style="height: 300px; width: 320px;">
<legend></legend>
<asp:Login ID="Login1" runat="server" UserNameLabelText="username:"
LoginButtonText="Log in" PasswordLabelText="Paswoord:"
PasswordRequiredErrorMessage="Password required." >
</asp:Login>
</fieldset>
</td>
<td valign="top">
<fieldset style="height: 300px; width: 320px;">
<legend></legend>
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" >
<WizardSteps>
<asp:CreateUserWizardStep ID="cuws1" runat="server">
<ContentTemplate>
<table border="0">
<tr>
<td align="center" colspan="2">
Make a new account</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel"
runat="server" AssociatedControlID="UserName">username:</asp:Label></td>
<td>
<asp:TextBox ID="UserName" runat="server"
MaxLength="20"></asp:TextBox>
<asp:RequiredFieldValidator
ID="UserNameRequired" runat="server" ControlToValidate="UserName"
Font-Size="Smaller"
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
...........
</asp:Content>
Mar 10 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.