Can't Figure Out Correct Syntax

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I am trying to code a Sub to store some custom values in a profile for a new
user registration (ASP.NET 2.0 environment). I copied the basic code from an
example I found in a great article
(http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx ) but one of
my controls is a calendar control - see the p.DOB line in the code - and I
cannot figure out the syntax to use. In the code below, the ", text" at the
end get flagged with the error "Type expected".

If anyone can explain what is expected there I would really appreiate it.

Wayne

================= Code ================
Public Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As
EventArgs)

' Create an empty Profile for the newly created user

Dim p As ProfileCommon =
CType(ProfileCommon.Create(CreateUserWizard1.UserName, True), ProfileCommon)

' Populate some Profile properties off of the create user wizard

p.DOB =
Date.Parse((CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("calDOB"),
Text)))

p.Sex =
(CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("rblSex"),
RadioButton)).Text

p.HomeState =
(CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("HomeState"),
TextBox)).Text

' Save profile - must be done since we explicitly created it

p.Save()

End Sub
 
Wayne said:
I am trying to code a Sub to store some custom values in a profile for a new
user registration (ASP.NET 2.0 environment). I copied the basic code from an
example I found in a great article
(http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx ) but one of
my controls is a calendar control - see the p.DOB line in the code - and I
cannot figure out the syntax to use. In the code below, the ", text" at the
end get flagged with the error "Type expected".

If anyone can explain what is expected there I would really appreiate it.

Wayne

================= Code ================
Public Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As
EventArgs)

' Create an empty Profile for the newly created user

Dim p As ProfileCommon =
CType(ProfileCommon.Create(CreateUserWizard1.UserName, True), ProfileCommon)

' Populate some Profile properties off of the create user wizard

p.DOB =
Date.Parse((CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("calDOB"),
Text)))

p.Sex =
(CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("rblSex"),
RadioButton)).Text

p.HomeState =
(CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("HomeState"),
TextBox)).Text

' Save profile - must be done since we explicitly created it

p.Save()

End Sub
Maybe because you're using date.parse, all you need is to change the
comma to a period,

p.DOB =
Date.Parse((CType(CreateUserWizard1.CreateUserStep.
ContentTemplateContainer.FindControl("calDOB").Text)))

I'm only guessing - I don't do asp.net.

Tom
 
Tom;
I appreciate the suggestion. That doesn't work. It flags the entire line as
"Text is not a member...). What is strange, when I use the "," Intellisense
offers lots of options, including "text"?

Wayne
 
Back
Top