1.

Solve : onFocus??

Answer»

Hello

If I have Code: [Select]<p><span>Name</span><input class="CONTACT" type="text" name="your_name" /></p> in an email Web contact page in an aspx file (ASP.NET) and this:

Code: [Select] Protected Sub Page_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Me.Load

        Dim yourname As String = Request.Form("your_name")
        Dim Name As String = "yourname"

       [b][color=red]yourname.Focus()[/color][/b]
   End Sub
in my aspx.vb file - I am trying to set focus in the user name FIELD - I get an error telling me that 'Focus' is not a member of String.

How should I be coding that then?

Thanks!

[attachment deleted by admin to conserve space]Request.Form returns a Form POST variable. You cannot set the focus because the form has already been submitted.

If you want to change the focus, you'll NEED to handle the onsubmit method with JavaScript within client-side code, or have the server-side validate and then re-display the form if an error occurs, but change, for example, labels to be red or show an error next to the field INDICATING the error.

Thanks for your reply.

This was not to highlight errors. This was just when a site visitor goes to the contact form page, the CURSOR is already flashing inside the the user_name field. So I thought it would be something like:

Code: [Select] Protected Sub Page_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Me.Load

        'your_name.Focus()

        End Sub

where your_name is the name of the input field:

Code: [Select] <p><span>Name</span><input class="contact" type="text" name="your_name" /></p>



Discussion

No Comment Found