Thank you so much, Dave.
It works beautifully!!!
I really appreciate your time and patience!
--
Sandy
"Dave Fancher" wrote:
[color=blue]
> You probably didn't see my reply to myself. I accidentally put an 's' on
> the end of 'style' so it wouldn't work. Using this line instead should
> clear up the problem for you. Sorry for the typo!
>
> txtNewUserName.Attributes.Add("onfocus", "document.getElementById('" +
> lblMessage.UniqueID + "').style.display = ""none"";")
>
> I also edited the line in your code below.
>
> HTH
> ----------------
> Dave Fancher
>
http://www.davefancher.com
>
> "Sandy" <Sandy@discussions.microsoft.com> wrote in message
> news:4FAACD18-78A3-4C8E-948E-3F095D1CDF80@microsoft.com...[color=green]
> > Dave -
> >
> > Thanks so much for your response! That sure looks like it should work,
> > but
> > it didn't. The lblMessage (which indicates the name is taken) did not
> > disappear when I put the cursor in the textbox, or even after I typed in
> > the
> > textbox and tabbed to the next textbox.
> >
> > Could I trouble you to take a look at the code? I put your solution at
> > the
> > end of the sub.
> >
> > Private Sub btnSubmitNewMember_Click(ByVal sender As System.Object, ByVal
> > e
> > As System.EventArgs) Handles btnSubmitNewMember.Click
> >
> > 'Check if User Name taken
> > Dim daTest as SqlDataAdapter
> > Dim dsLogin as New DataSet
> > daTest = New SqlDataAdapter("Select Count(UserID) as TheCount " _
> > & "from tblLogin Where " _
> > & "UserName = '" & txtNewUserName.Text _
> > & "'", cnn)
> > daTest.Fill(dsLogin, "TheCount")
> >
> > Dim NewValue as Integer
> > NewValue = dsLogin.Tables("TheCount").Rows(0).Item("TheCount" )
> > 'If User Name is taken, it will return a 1; otherwise if not taken,
> > will
> > return 0 and User Name is okay
> > If dsLogin.Tables("TheCount").Rows(0).Item("TheCount" ) = 0 Then
> >
> > Dim cmdLogin as SqlCommand = cnn.CreateCommand
> > cmdLogin.CommandType = CommandType.StoredProcedure
> > cmdLogin.CommandText = "spTblLoginOnly"
> >
> > cmdLogin.Parameters.Add(New SqlParameter("@UserName", SqlDbType.Char,
> > 50))
> > cmdLogin.Parameters("@UserName").Value = txtNewUserName.Text
> > cmdLogin.Parameters.Add(New SqlParameter("@Password", SqlDbType.Char,
> > 15))
> > cmdLogin.Parameters("@Password").Value = txtNewPassword.Text
> > cmdLogin.Parameters.Add(New SqlParameter("@EmailAddress",
> > SqlDbType.Char, 60))
> > cmdLogin.Parameters("@EmailAddress").Value = txtEmail.Text
> > cmdLogin.Parameters.Add(New SqlParameter("@ScreenName", SqlDbType.Char,
> > 15))
> > cmdLogin.Parameters("@ScreenName").Value = txtScreenName.Text
> >
> > cmdLogin.Parameters.Add(New SqlParameter("@UserID", SqlDbType.Int))
> > cmdLogin.Parameters("@UserID").Direction = ParameterDirection.Output
> > cnn.Open
> > cmdLogin.ExecuteNonQuery()
> > 'Get the UserName from tblLogin and put it into Session
> > daTest = New SqlDataAdapter("Select UserID from tblLogin Where " _
> > & "UserName = '" & txtNewUserName.Text _
> > & "' and Password = '" & txtNewPassword.Text _
> > & "'", cnn)
> > daTest.Fill(dsLogin, "tblLogin")
> > Session("UserID") = dsLogin.Tables("tblLogin").Rows(0).Item("UserID")
> >
> > cnn.Close
> >
> >
> > Response.Redirect(HttpUtility.UrlDecode(Request.Qu eryString("currpage")))
> >
> > Else
> > pnlNewMember.Visible = True
> >
> > lblMessage.Text = "The User Name you entered is already in use. Please
> > choose a different User Name."
> > txtNewUserName.Attributes.Add("onfocus", "document.getElementById('" +
> > lblMessage.UniqueID + "').style.display =""none"";")
> >
> > End If
> >
> > End Sub
> >
> > What am I doing wrong?
> >
> >
> > --
> > Sandy
> >
> >
> > "Dave Fancher" wrote:
> >[color=darkred]
> >> I prefer the option of just hiding it.
> >>
> >> Assuming that your TextBox is named userName and your Label is named
> >> errorLabel you could use the following code to add the client side event
> >> handler to the TextBox. I would recommend placing this code somewhere
> >> where
> >> it will only be executed when the label is going to be marked as visible.
> >>
> >> [C#]
> >> userName.Attributes.Add("onfocus", "document.getElementById('" +
> >> errorLabel.UniqueID + "').styles.display = \"none\";");
> >>
> >> [VB - sorry if my syntax is slightly off]
> >> userName.Attributes.Add("onfocus", "document.getElementById('" +
> >> errorLabel.UniqueID + "').styles.display = ""none"";");
> >>
> >> HTH
> >> ----------------
> >> Dave Fancher
> >>
http://www.davefancher.com
> >>
> >> "Sandy" <Sandy@discussions.microsoft.com> wrote in message
> >> news:51211DC1-571B-4A95-9C72-1908E4F3B9A2@microsoft.com...
> >> > John -
> >> >
> >> > Thanks for your response.
> >> >
> >> > Sorry for being dense, but I know absolutely nothing about javascript -
> >> > it
> >> > is the next thing on my agenda to learn.
> >> >
> >> > Can you tell me where and how I would put this in my code?
> >> >
> >> >
> >> > --
> >> > Sandy
> >> >
> >> >
> >> > "John Timney (ASP.NET MVP)" wrote:
> >> >
> >> >> Use CSS in a javascript onfocus event
> >> >>
> >> >>
http://msdn.microsoft.com/workshop/a...ts/onfocus.asp
> >> >>
> >> >> labelID.style.visibility = ' hidden ';
> >> >>
> >> >> or move the label off screen with javascript
> >> >>
> >> >> function moveTo(x, y) {
> >> >> this.element.left = x;
> >> >> this.element.top = y;
> >> >> }
> >> >>
> >> >> --
> >> >> Regards
> >> >>
> >> >> John Timney
> >> >> ASP.NET MVP
> >> >> Microsoft Regional Director
> >> >>
> >> >> "Sandy" <Sandy@discussions.microsoft.com> wrote in message
> >> >> news:F326954F-206F-4E89-9EE3-91727E5CE13F@microsoft.com...
> >> >> > Hello -
> >> >> >
> >> >> > I have a form that when submitted checks the database and if the
> >> >> > username
> >> >> > is
> >> >> > already taken, a label shows indicating same.
> >> >> >
> >> >> > I need to make that label NOT visible after the user clicks in the
> >> >> > username
> >> >> > textbox to change the name.
> >> >> >
> >> >> > Any help will be greatly appreciated!
> >> >> >
> >> >> > --
> >> >> > Sandy
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>[/color][/color]
>
>
>[/color]