473,573 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LOGIN Controls & Setting Focus--NEED HELP PLEASE

Good morning friends,

I am working with Visual Studio 2005, ASP.NET 2.0

I am working with the Login controls provided my .NET 2.0, trying to make
the Login1 control UserName textbox obtain SetFocus upon load of the .aspx
web page but I cannot for the life of me get this to work. I tried using
the defaultfocus on the Form but that did not work.
My code in my MasterPage is as follow::::
<form runat=server id="aspLoginFor m">
<script language='JavaS cript' type="text/javascript">
<!--
function SetFocus()
{
document.aspLog inForm['Login1_UserNam e'].focus();
}
window.onload = SetFocus;
// -->
</script>
<div>
<br />
<br />
<br />
&nbsp;</div>
<br />
<br />
<br />
<br />
<br />
<asp:Login ID="Login1" runat="server"
Any ideas would be greatly apprecited.

Thanks in advance,

~Brad


Jan 19 '07 #1
8 2131
"Brad Isaacs" <bi*****@rogers .comwrote in message
news:OC******** ********@TK2MSF TNGP03.phx.gbl. ..
window.onload = SetFocus;
window.onload = SetFocus();
Jan 19 '07 #2
dgk
On Fri, 19 Jan 2007 11:09:55 -0500, "Brad Isaacs" <bi*****@rogers .com>
wrote:
>Good morning friends,

I am working with Visual Studio 2005, ASP.NET 2.0

I am working with the Login controls provided my .NET 2.0, trying to make
the Login1 control UserName textbox obtain SetFocus upon load of the .aspx
web page but I cannot for the life of me get this to work. I tried using
the defaultfocus on the Form but that did not work.

I just did

Login1.Focus()

in Page_Load.

Is that what you mean?
Jan 19 '07 #3
Hey again,

Thanks MarK Rae for my typo on .setFocus()

Login1.focus in the Page Load references an NULL object.

I am trying to use the Javascript code inside my HTML

<form runat=server id="aspLoginFor m">

<script language='JavaS cript' type="text/javascript">

<!--

function SetFocus()

{

document.aspLog inForm['Login1_LayoutT emplate_UserNam e'].focus();

}

window.onload = SetFocus();

// -->

</script>

But it is not working at all............ .... So I thought I of using another
method......... ....

Any ideas?

Thanks in advance,

~Brad

"dgk" <dg*@somewhere. comwrote in message
news:j3******** *************** *********@4ax.c om...
On Fri, 19 Jan 2007 11:09:55 -0500, "Brad Isaacs" <bi*****@rogers .com>
wrote:
>>Good morning friends,

I am working with Visual Studio 2005, ASP.NET 2.0

I am working with the Login controls provided my .NET 2.0, trying to make
the Login1 control UserName textbox obtain SetFocus upon load of the .aspx
web page but I cannot for the life of me get this to work. I tried using
the defaultfocus on the Form but that did not work.


I just did

Login1.Focus()

in Page_Load.

Is that what you mean?

Jan 19 '07 #4
"Brad Isaacs" <bi*****@rogers .comwrote in message
news:Oz******** ********@TK2MSF TNGP06.phx.gbl. ..
<form runat=server id="aspLoginFor m">
Ah yes, but you're using MasterPages aren't you...? Do a View Source and
you'll see that ASP.NET has (for reasons which I've never understood)
renamed your form to 'aspnetForm'

Are you even sure your JavaScript function is being called...? Try this:

alert('1');
document.getEle mentById('<%=Us erName.ClientID %>').focus();
alert('2');

How many alerts do you get...?
Jan 19 '07 #5
dgk
On Fri, 19 Jan 2007 17:08:18 -0000, "Mark Rae"
<ma**@markNOSPA Mrae.comwrote:
>"Brad Isaacs" <bi*****@rogers .comwrote in message
news:Oz******* *********@TK2MS FTNGP06.phx.gbl ...
><form runat=server id="aspLoginFor m">

Ah yes, but you're using MasterPages aren't you...? Do a View Source and
you'll see that ASP.NET has (for reasons which I've never understood)
renamed your form to 'aspnetForm'

Are you even sure your JavaScript function is being called...? Try this:

alert('1');
document.getEl ementById('<%=U serName.ClientI D%>').focus();
alert('2');

How many alerts do you get...?
I don't understand why he gets a null reference since I'm using a
masterpage also. This is my whole page_load for login.aspx:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
CType(Master, PRDUA).HideLogi n()
Login1.Focus()
End Sub

The first line is just calling a function on the master page to hide
the login/logout link if you're on the login page. The second
successfully sets the focus to the login control.
Jan 19 '07 #6
If you get the two alerts but it's still not setting the focus, change
alert('1') to the word debugger; and remove alert('2'). If you are browsing
with Internet Explorer go to Tools menu, Internet Options, Advanced Tab and
remove the checkbox "Disable script debugging (Internet Explorer)".
Also, the second alert could cause the focus to be lost depending on the
browser you are using, probably best to change that one to window.status =
"2";
The word debugger in the client code will kick of client side debugging.

Mark's example is really a best practice especially if you are using user
controls or master pages as the control id will change depending on the
number of controls and / or the nesting.

I don't know what browser compatibility level you are looking for... but the
getElementById is the most compatible method; it will work on any DOM
capable browser and on all new browsers. Older browsers you would probably
need to-do a test something like this..

if (document.getEl ementById)
document.getEle mentById('<%=Us erName.ClientID %>').focus();
else if (document.all)
document.all('< %=UserName.Clie ntID%>').focus( );
else if (document.layer s)
document.layers ('<%=UserName.C lientID%>').foc us();
Regards,
Brian K. Williams

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:eM******** ********@TK2MSF TNGP02.phx.gbl. ..
"Brad Isaacs" <bi*****@rogers .comwrote in message
news:Oz******** ********@TK2MSF TNGP06.phx.gbl. ..
><form runat=server id="aspLoginFor m">

Ah yes, but you're using MasterPages aren't you...? Do a View Source and
you'll see that ASP.NET has (for reasons which I've never understood)
renamed your form to 'aspnetForm'

Are you even sure your JavaScript function is being called...? Try this:

alert('1');
document.getEle mentById('<%=Us erName.ClientID %>').focus();
alert('2');

How many alerts do you get...?

Jan 19 '07 #7
Hey again,

WOW -- the madness has ended.
The Javascript was not firing......... . I could not see any alerts, I messed
around and found that if I took out the Javascript and used the Page_Load or
Login1_Load events, then it worked using "dgk" Login1.focus()

This worked:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Handles Me.Load

Login1.Focus()

End Sub

Protected Sub Login1_Load(ByV al sender As Object, ByVal e As
System.EventArg s) Handles Login1.Load

Login1.Focus()

End Sub

Onto my next adventure...... ...

Thank you both for all your help/input.........

Very much appreciated,

~BRad

"dgk" <dg*@somewhere. comwrote in message
news:eo******** *************** *********@4ax.c om...
On Fri, 19 Jan 2007 17:08:18 -0000, "Mark Rae"
<ma**@markNOSPA Mrae.comwrote:
>>"Brad Isaacs" <bi*****@rogers .comwrote in message
news:Oz****** **********@TK2M SFTNGP06.phx.gb l...
>><form runat=server id="aspLoginFor m">

Ah yes, but you're using MasterPages aren't you...? Do a View Source and
you'll see that ASP.NET has (for reasons which I've never understood)
renamed your form to 'aspnetForm'

Are you even sure your JavaScript function is being called...? Try this:

alert('1');
document.getE lementById('<%= UserName.Client ID%>').focus();
alert('2');

How many alerts do you get...?

I don't understand why he gets a null reference since I'm using a
masterpage also. This is my whole page_load for login.aspx:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
CType(Master, PRDUA).HideLogi n()
Login1.Focus()
End Sub

The first line is just calling a function on the master page to hide
the login/logout link if you're on the login page. The second
successfully sets the focus to the login control.

Jan 19 '07 #8
DGK,

Your code is running on the server and will resolve the client id. His code
is client side code and doesn't know what the client id will be. Mark's
example code changed that so he is getting the client id from the server.

Regards,
Brian K. Williams

"dgk" <dg*@somewhere. comwrote in message
news:eo******** *************** *********@4ax.c om...
On Fri, 19 Jan 2007 17:08:18 -0000, "Mark Rae"
<ma**@markNOSPA Mrae.comwrote:
>>"Brad Isaacs" <bi*****@rogers .comwrote in message
news:Oz****** **********@TK2M SFTNGP06.phx.gb l...
>><form runat=server id="aspLoginFor m">

Ah yes, but you're using MasterPages aren't you...? Do a View Source and
you'll see that ASP.NET has (for reasons which I've never understood)
renamed your form to 'aspnetForm'

Are you even sure your JavaScript function is being called...? Try this:

alert('1');
document.getE lementById('<%= UserName.Client ID%>').focus();
alert('2');

How many alerts do you get...?

I don't understand why he gets a null reference since I'm using a
masterpage also. This is my whole page_load for login.aspx:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
CType(Master, PRDUA).HideLogi n()
Login1.Focus()
End Sub

The first line is just calling a function on the master page to hide
the login/logout link if you're on the login page. The second
successfully sets the focus to the login control.

Jan 19 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7100
by: ad | last post by:
I have create a custom membership provider. The common usage of custom membership is set it as default Membership Provider win web.config, and use login controls with it. How can I use custom membership provider without Login Controls? For example, the name of my custom membership provider MyMembershipProvider. Is the codes below right?...
5
1471
by: Seok Bee | last post by:
Dear Experts, I an trying to use the Login controls in asp.net 2.0 in the Visual Studio 2005. I have created the login page as login.aspx and set the DestinationPageUrl to ont of my webpage. I have included the Loginname control in my destination webpage to show the current user who is logging in. However, after I login through the login...
1
1284
by: Roman | last post by:
To confirm that the e-mail supplied in the new user wizard is correct, I would like to a) change the new user template not to contain password. b) I would like to send system generated password to the user asking them to change it on the next login attempt. What would be the easiest way to accomplish this? (I suppose working with login...
0
1166
by: brown | last post by:
We started an asp.net 2.0 web site with the new login controls. It seems like the Membership and MembershipUser functionality is attached to the web site, so all the web pages for the site will have to be in the same project, in this correct? We are using the asp.net web application project model instead of the new asp.net 2.0 web site model...
2
3189
by: pj | last post by:
I'm using asp.net 2.0 login controls, When a user forgets a password, they are sent an email with the new password. Two questions.... 1) how do I format the password that is being created to be only letters and numbers? Not something like "e%QtT6.Eja%XNG" 2) how do I redirect users to a change password page, next time they login with...
1
6423
by: pj | last post by:
I'm trying to redirect users to another page after they Authenticate with the ASP.NET login controls. The user is able to login, but I can't get the response.redirect to work. Can anyone help? My code is below. Thanks, pj mcdba, mcp
0
5252
by: muder | last post by:
I have a standard Login ASP.NET 2.0 control on a login Page, a LoginName and LoginStatus controls on the member's page. once the user login successfully I am redirecting the user to Member.aspx page. The following is my machine configuration Windows XP Pro Service Pack2 IIS 5.1 SQL Server 2000 visual Studio 2005 DISABLE ANONMYOUS...
1
1265
by: Vince | last post by:
Hi, While working with the Login controls, VS creates a ASPNETDB.MDF database to store user accounts. Is that database only used for the storage of login credentials and if so, does this mean my site will need a separate database to host a users profile information and other tables Ill be needing?
4
1284
by: shilpareddy2787 | last post by:
Hi, I am new to asp.net. I created an application using login controls.Now I have a problem. In SQLserver I have a database. In that I created a signup table. the data which I enter in sign up application which contains username,password and email are stored in to that table.when user wants to login he enters username and password, Now these...
0
7686
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8009
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8198
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5289
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3730
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2194
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1296
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1036
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.