Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot pick the email textbox

Status
Not open for further replies.

stevet26

Programmer
Feb 9, 2005
53
Hi

I have setup a createuserwizard for my site. the actual login creation form come right at the end of the wizard because I need to take payment information beofre I can create the account.

Due to the fact I have to take information to make a payment before I create the user account, this means that I already have the users email address before I reach to create user form of the wizard.

Now save them having to re enter their email address in again I would like to use the email address I have taken earlier in the wizard. However I am finding it very difficult to access the email textbox in the create user form.

To try an beat this I have created a custom template for the create user form. Thinking that the textbox would get picked up if it is physically entered on to the aspx page. However this does not seem to work either.

Does anyone know if there is a way of solving my problem.

Please find the code I use for the CreateUserWizardStep below:

<code>
<asp:CreateUserWizardStep ID="wzdCreateUser" Title="Member Login Details" runat="server" OnActivate="wzdCreateUser_OnActivate">
<ContentTemplate>

<asp:ObjectDataSource ID="odsSecurityQuestion" runat="server" SelectMethod="GetSecurityQuestions" TypeName="MI.Website.Helpers"/>

<ol>

<li>
<asp:Label ID="lblUsername" runat="server" AssociatedControlID="UserName">UserID:</asp:Label><asp:TextBox runat="Server" ID="UserName" />
<asp:RequiredFieldValidator runat="server" ID="reqUsername" ControlToValidate="UserName" ErrorMessage="You need to enter a username" Text="*" />
</li>
<li>
<asp:Label ID="lblPassword" runat="server" AssociatedControlID="Password">Password:</asp:Label><asp:TextBox runat="Server" ID="Password" />
<asp:RequiredFieldValidator runat="server" ID="reqPassword" ControlToValidate="Password" ErrorMessage="You need to enter a Password" Text="*" />
</li>
<li>
<asp:Label ID="lblConfirmPassword" runat="server" AssociatedControlID="ConfirmPassword">Re-Type Password:</asp:Label><asp:TextBox runat="Server" ID="ConfirmPassword" />
<asp:CompareValidator runat="server" ID="compPassword" ControlToValidate="ConfirmPassword" ControlToCompare="Password" ErrorMessage="Password must match" Text="*" />
</li>
<li>
<asp:Label ID="lblEmail" runat="server" AssociatedControlID="Email">Email:</asp:Label><asp:TextBox runat="Server" ID="Email" />
</li>
<li>
<asp:Label ID="lblQuestion" runat="server" AssociatedControlID="Question">Security Question:</asp:Label>
<asp:DropDownList ID="Question" runat="server" DataSourceID="odsSecurityQuestion">
</asp:DropDownList>
</li>
<li>
<asp:Label ID="lblAnswer" runat="server" AssociatedControlID="Answer">Security Answer:</asp:Label><asp:TextBox runat="Server" ID="Answer" />
<asp:RequiredFieldValidator runat="server" ID="reqAnswer" ControlToValidate="Answer" ErrorMessage="You need to enter a Security Answer" Text="*" />
</li>

</ol>

</ContentTemplate>
</asp:CreateUserWizardStep>
</code>

This is the code behind I have tried (but failed with):

<code>
protected void wzdCreateUser_OnActivate(object sender, EventArgs e)
{

TextBox Email = (TextBox)wzdCreateUser.FindControl("Email");

Email.Text = txtEmail.Text;

}
</code>

Thanking you in advance.
 
Email.Text = txtEmail.Text;

is the txtEmail control on the same page at time of postback or on a diff page?
 
Hi

Thanks for the reply.

The txtEmail is on the same page, but a different step and when I debug I have no problem getting its value.

The problem I am experiencing is with Email.Text. Intellisense does not pick up the control in the CreateUserWizardStep. That is why I has to use FindControl.

Hoever even then it still cannot locate Email on the page.

It is as if everthing within the contentTemplate does not exist!
 
sample..

Code:
  'How to access controls inside templated CreateUser wizard step.   
    Sub PhoneWrite(ByVal sender As Object, ByVal e As EventArgs)
        Label4.Text = "Your Phone number is:"
        Dim myStep As New CreateUserWizardStep
    Dim myText As TextBox = CreateUserWizardStep1.ContentTemplateContainer.FindControl("TextBoxPhone")
        CreateUserWizardStep1.ContentTemplateContainer.FindControl("TextBoxPhone")
    Label5.Text = Server.HtmlEncode(myText.Text)
    End Sub
 
sry...heres c#

//How to access a control in a templated CreateUserStep
void PhoneWrite(object sender, EventArgs e)
{
Label4.Text = "Your Phone number is:";
CreateUserWizardStep myStep = new CreateUserWizardStep();
Label5.Text = Server.HtmlEncode(((TextBox)(CreateUserWizardStep1.ContentTemplateContainer.FindControl("TextBoxPhone"))).Text); ;
}
 
Cool that works. It didn't occur to me that you would need to include "ContentTemplateContainer", but I guess it makes sense!

Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top