When a web form loads, how can I make the cursor start in a specific text box?
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 Object, ByVal e 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