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 btnSubmitNewMem ber_Click(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles btnSubmitNewMem ber.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(dsL ogin, "TheCount")
Dim NewValue as Integer
NewValue = dsLogin.Tables( "TheCount").Row s(0).Item("TheC ount")
'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").Row s(0).Item("TheC ount") = 0 Then
Dim cmdLogin as SqlCommand = cnn.CreateComma nd
cmdLogin.Comman dType = CommandType.Sto redProcedure
cmdLogin.Comman dText = "spTblLoginOnly "
cmdLogin.Parame ters.Add(New SqlParameter("@ UserName", SqlDbType.Char, 50))
cmdLogin.Parame ters("@UserName ").Value = txtNewUserName. Text
cmdLogin.Parame ters.Add(New SqlParameter("@ Password", SqlDbType.Char, 15))
cmdLogin.Parame ters("@Password ").Value = txtNewPassword. Text
cmdLogin.Parame ters.Add(New SqlParameter("@ EmailAddress",
SqlDbType.Char, 60))
cmdLogin.Parame ters("@EmailAdd ress").Value = txtEmail.Text
cmdLogin.Parame ters.Add(New SqlParameter("@ ScreenName", SqlDbType.Char,
15))
cmdLogin.Parame ters("@ScreenNa me").Value = txtScreenName.T ext
cmdLogin.Parame ters.Add(New SqlParameter("@ UserID", SqlDbType.Int))
cmdLogin.Parame ters("@UserID") .Direction = ParameterDirect ion.Output
cnn.Open
cmdLogin.Execut eNonQuery()
'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(dsL ogin, "tblLogin")
Session("UserID ") = dsLogin.Tables( "tblLogin").Row s(0).Item("User ID")
cnn.Close
Response.Redire ct(HttpUtility. UrlDecode(Reque st.QueryString( "currpage") ))
Else
pnlNewMember.Vi sible = True
lblMessage.Text = "The User Name you entered is already in use. Please
choose a different User Name."
txtNewUserName. Attributes.Add( "onfocus", "document.getEl ementById('" +
lblMessage.Uniq ueID + "').styles.disp lay =""none"";")
End If
End Sub
What am I doing wrong?
--
Sandy
"Dave Fancher" wrote:
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.Attrib utes.Add("onfoc us", "document.getEl ementById('" +
errorLabel.Uniq ueID + "').styles.disp lay = \"none\";");
[VB - sorry if my syntax is slightly off]
userName.Attrib utes.Add("onfoc us", "document.getEl ementById('" +
errorLabel.Uniq ueID + "').styles.disp lay = ""none"";") ;
HTH
----------------
Dave Fancher
http://www.davefancher.com
"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:51******** *************** ***********@mic rosoft.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.v isibility = ' hidden ';
or move the label off screen with javascript
function moveTo(x, y) {
this.element.le ft = x;
this.element.to p = y;
}
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:F3******** *************** ***********@mic rosoft.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