Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2007, 06:50 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default Tip: Setting focus on login control

After much searching and experimentation, i finally found a way to get the focus onto the login control of my page (i've moved it from the template.master to the AccessDenied.aspx page). just add the following code into your page:

        protected void Page_PreRender(object sender, EventArgs e)
        {
            //Find the Login control inside the LoginView
            System.Web.UI.WebControls.Login curLogin = (System.Web.UI.WebControls.Login)LoginView1.FindCo ntrol("Login1");
            //Then find the Username textbox control
            if (curLogin != null)
            {
                TextBox txtUsername = (TextBox)curLogin.FindControl("UserName");
                //Now set the focus on it
                txtUsername.Focus();
            }
            else
            {
                this.Response.Redirect("default.aspx", false);
                this.Response.End();

            }
        }

not sure if it'll work in the masterpage scenarion, but works great in the AccessDenied (or new Login.aspx) page.


jimi

http://www.jamestollan.com
__________________
jimi

http://www.originaltalent.com
 
Old April 16th, 2007, 07:23 AM
Authorized User
 
Join Date: Mar 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello jimi!
I have added this on page template.master with the exclusion of

     else
            {
                this.Response.Redirect("default.aspx", false);
                this.Response.End();

            }
But

Enterring name and password and having pressed button Enter focus of the entering not always moves to button Submit. Possible somehow this correct?

With best wishes Mary.

 
Old April 16th, 2007, 01:50 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Mary,

As i said, i moved my code for the login out of the template.master and into AccessDenied.aspx. i'm not sure how this would work in the master template (it seemed a bit risky and unergonomic to me), so i haven't tried it from there i'm afraid.

take a look at my jamestollan.com page and you'll see how i redid this bit.

jimi

http://www.jamestollan.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Query Focus. eusanpe Access VBA 4 June 4th, 2008 10:20 AM
Setting Focus on a Sub Form Brendan Bartley Access 1 August 8th, 2005 02:41 AM
Setting the Focus BSkelding ASP.NET 1.0 and 1.1 Professional 1 May 12th, 2005 01:40 PM
Setting focus to a web control textbox? hilda ASP.NET 1.0 and 1.1 Basics 2 November 1st, 2003 11:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.