Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2007, 05:50 PM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to access with code-behind a label embedded in

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
H.

 
Old March 10th, 2007, 03:04 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

Try the below:

Dim lbl As Label
lbl = CType(CreateUserWizard1.WizardSteps(1).FindControl ("UserNameLabel"), Label)

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old March 10th, 2007, 06:10 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mike,

Thanks for replying.

Unfortunately, i get an error:
"Object reference not set to an instance of an object"
at the last line:

Dim lb As New Label
lb = CType(CreateUserWizard1.WizardSteps(1).FindControl ("UserNameLabel"), Label)
lb.Text = "yes"

 
Old March 12th, 2007, 06:47 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

Please post the entire (relevant code) so that we can trace the error.

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded code in Reporting Services 2005 gunjan.sh C# 2005 1 February 19th, 2008 09:04 AM
Label onmouseover in code behind wareclause ASP.NET 2.0 Basics 11 February 5th, 2007 06:00 PM
Access XML fragments embedded in Word 2003 debsoft General .NET 2 May 7th, 2004 07:55 AM
Apply VBA Code To Report Label If Possible Ben Horne Access VBA 3 February 18th, 2004 10:12 AM
HTML: <FORM> embedded in code valentino HTML Code Clinic 1 July 9th, 2003 10:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.