views:

140

answers:

1

Hi,

I have an aspxtextbox e.g

  <dxe:ASPxTextBox ID="txtZip" runat="server" Width="150">
                            <MaskSettings Mask="00000" ErrorText="Please input missing symbols" />
                            <ValidationSettings ErrorDisplayMode="ImageWithTooltip" />
                        </dxe:ASPxTextBox>

How can I modify it so that when the user goes to the textbox, it will always position the cursor at index 0, or the last entered character?

Thanks,

Jacob

+1  A: 

Hi Jacob,

This can be done by handling the editor's client side GotFocus event handler. Here is some sample code:

<dxe:ASPxTextBox ID="txtZip" runat="server" Width="150">
                    <MaskSettings Mask="00000" ErrorText="Please input missing symbols" />
                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" />
                    <ClientSideEvents GotFocus="
                    function(s,e) {
                        var editorValue = s.GetValue();
                        if(editorValue)
                            s.SetCaretPosition(editorValue.toString().length);
                    }" />
                </dxe:ASPxTextBox>
DevExpress Team