473,769 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET 2.0 Login control

Does anybody know a way to make the button on the Login control be the
default button on the page? I have a master page with an ImageButton and a
content page with a Login control. When I enter the id and password and
press the Enter key, the ImageButton (on the master page) fires instead of
the Login button of the Login control on the content page. The Login
composite control does not appear to expose a reference to its button.

Thanks in advance
Jan 27 '06 #1
5 1590
Try placing it within a Panel control and setting the DefaultButton
attribute.

David Barkol
www.neudesic.com

Jan 27 '06 #2
The problem is that to set a button as the default button, it must implement
the IButtonControl interface. The Login control does not implement the
IButtonControl interface and the button inside the Login control is not
exposed. I tried Form.DefaultBut ton = "Login1" and it will not compile. Your
solution would require something like: Panel1.DefaultB utton = "Login1"
(correct me if I am wrong).

Certainly Microsoft has thought this through??


"David Barkol" wrote:
Try placing it within a Panel control and setting the DefaultButton
attribute.

David Barkol
www.neudesic.com

Jan 27 '06 #3
You're right. In this case you are going to have to use your own
controls and leverage the Membership API's to validate the login.

Jan 27 '06 #4
David,

Thanks for your interest. I chose to workaround it by disabling the
ImageButton (on the master page) during the Login process. Works fine but
its technically a kluge.

Have a great weekend,

Glen

"David Barkol" wrote:
You're right. In this case you are going to have to use your own
controls and leverage the Membership API's to validate the login.

Jan 27 '06 #5
hi glen,

i had the same problem (login control in page and imagebutton in
masterpage).

the whole asp.net page is usually a form so you have to set the default
button for that main form.

in the Page_Load function of your web page get a reference to the main
form ("form1") which is in master page:

HtmlForm mainform = (HtmlForm)Maste r.FindControl(" form1");

then get a reference to your login button in the login control (convert
your login control in a editable template and you'll see the ID of the
button, however this ID is not directly accessable yet, you have to
search for it with FindControl):

Button loginbtn = (Button)myLogin Control.FindCon trol("LoginButt on");

your main form then wants a unique ID of the default button:

mainform.Defaul tButton = loginbtn.Unique ID;

here's the complete code:

protected void Page_Load(objec t sender, EventArgs e)
{
myLoginControl. Focus();
HtmlForm mainform = (HtmlForm)Maste r.FindControl(" form1");
Button loginbtn =
(Button)myLogin Control.FindCon trol("LoginButt on");
if (mainform != null && loginbtn != null)
{
mainform.Defaul tButton = loginbtn.Unique ID;
}
}

i got this information searching the msdn asp.net documentation and it
works fine. however there's one problem still:

when the login control is configured to "refresh" itself on the client
side without reloading the page from the server if the validation
failed (e.g. no password entered) then it will reset the default button
(makes absolutely no sense to me!)

hope this helps. let me know if find out something about the refresh
issue.

simon

Feb 4 '06 #6

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

Similar topics

3
2883
by: koolyio | last post by:
Hey, could you please tell me what is wrong with my login script. I just started learning php. CODE: login.php <? session_start(); header("Cache-Control: private"); ?>
0
1294
by: Steve Commisso | last post by:
I'm trying to create a forked login where users of certain roles will be redirected to specific pages. The easy way to do this would be to do the redirecting in the Page_Load() of the default page after login, but I'd like to skip this step and just have the Login control go ahead and do it. So my plan is this: override the OnLoggedIn() method of the Login control with my own custom method that changes the DestinationPageUrl property...
14
2633
by: clintonG | last post by:
This is an appeal for peer support sent to Microsoft as will be noted in closing. The Login control does not include a Cancel button. The only option is to convert the Login control to a template which is not such a bad thing in itself but it means all other controls in the application must also be converted to templates to maintain a consistent UI. So much for writing 70% less code when foolish morons release a control with no cancel...
1
4538
by: EricRybarczyk | last post by:
I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0. The existing ASP application has several types of users, each with a separate login process (separate login page, separate DB tables, etc). For one of these user types, the current application has an additional input field required for login… they have a username, password, and another “location code” field. Please don’t make me explain or justify this…...
1
6985
by: Jeff Lynch | last post by:
I'd like to add the following attributes to the Login control's Login Button to create a CSS rollover effect. How can I access the control's login button from the page's code-behind? LoginButton.Attributes.Add("onmouseover", "this.className = 'buttonsmallover'"); LoginButton.Attributes.Add("onmouseout", "this.className = 'buttonsmall'"); -- Jeff Lynch
3
5790
by: ilockett | last post by:
The background: I have a web app with a simple master page that contains just one content placeholder. I have created a web form that then uses this master page. Within the content placeholder, I have placed a Login control (Login1) and a ValidationSummary control. I have set the ValidationSummary's ValidationGroup property equal to "Login1".
5
1922
by: Afshar | last post by:
Hi everybody there, I have a special Login page that wants users to enter 3 passwords rather than a single password. But can't do it with Login control. I tried following scenarios: 1. Put an Login in the page and set its Visible = False instead put my own username and 3 password on the form. Then I checked 2nd and 3rd password seperately and passed username and password to Login control via its Username and Password properties but...
2
4515
by: IdleBrain | last post by:
Hello All: I used a Login control to authenticate a user to login. The problem is that when I login with good username & password, the login view would say that the login was successful. But for some reason the login control does not redirect the control to DestinationPageUrl. Even when I hardcoded to redirect to another page, it still remains in the same page on successful login.
6
3360
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in the past in other places, and while the help was much appreciated, it seemed everyone just wanted to 'theoretically' explain how to do it, but when I tried to do it myself, I couldn't login. I want to simply pass the email address and password to...
6
8080
by: dan | last post by:
Hi, Could someone please let me know how to center a Login control on a page? Can I use CSS to do that? Thanks, Dan
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9423
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7409
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
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
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.