WorkflowGen.com | Knowledge Base | Documentation | Downloads | Support | RSS

« How to make the FileUpLoad control display as a link to the file. | Main | How can I set the maximum length of a multi-line text box in a web form? »

When a web form loads, how can I make the cursor start in a specific text box?

Posted on Sunday, February 17, 2008 at 09:58 by Registered CommenterWFG Team in | CommentsPost a Comment

If you want the cursor to start in a specific text box add the following line of code in your application:

C#

this.FIELDNAME.Focus();

VB

Me.FIELDNAME.Focus

You could add it to the page load function as follows:

C#

    protected void Page_Load(object sender, EventArgs e) {
        
switch (this.CurrentWorkflowActionName) {
            
case "INITIATES":
                
// If current action is INITIATES, do some work
                
this.FIELDNAME.Focus();
                break;
            case "APPROVES"
:
                
// If current action is APPROVES, do some work
                //  write code here
                
break;
        
}
    }

 VB

    Protected Sub Page_Load(ByVal sender As ObjectByVal As EventArgs)
        
Select Case (Me.CurrentWorkflowActionName)
            
Case "INITIATES"
                
'If current action is INITIATES, do some work
                
Me.FIELDNAME.Focus
            
Case "APPROVES"
                
'If current action is APPROVES, do some work
                ' write code here
        
End Select
    End Sub

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.
Member Account Required
You must have a member account on this website in order to post comments. Log in to your account to enable posting.