Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left Align Cursor in Gridview Template Field 2

Status
Not open for further replies.

Waynest

Programmer
Jun 22, 2000
321
GB
Hi

In gridview when user clicks the update button, then clicks into a text field he wants to edit, the cursor is being positioned where he clicks inside the box.

Is it possible to make the cursor be positioned at the leftmost position when the user clicks on the box?

Thankyou
 
Tested with textboxes with one and two words in them. IE7, in a datagrid EditItemTemplate

Javascript
Code:
function leftmost(clicked)
{    
    var rng = clicked.createTextRange();
    rng.move("sentence",-1);
    rng.select();
}

.net 2.0 html
Code:
<EditItemTemplate>
    <div>
        Name:
        <asp:TextBox ID="linkName" Width="150" Text='<%# Eval("linkName") %>' runat="server"
            onfocus="leftmost(this);" />
        <br />
        Categ:
        <asp:TextBox ID="linkCategory" Width="150" Text='<%# Eval("linkCategory") %>' runat="server"
            onfocus="leftmost(this);" />
    </div>
</EditItemTemplate>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top