Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - ASP.NET 2.0 Login control

 
Thread Tools Search this Thread
Old 01-27-2006, 03:47 PM   #1
Default 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


=?Utf-8?B?R2xlbg==?=
  Reply With Quote
Old 01-27-2006, 05:56 PM   #2
David Barkol
 
Posts: n/a
Default Re: ASP.NET 2.0 Login control
Try placing it within a Panel control and setting the DefaultButton
attribute.

David Barkol
www.neudesic.com



David Barkol
  Reply With Quote
Old 01-27-2006, 07:08 PM   #3
=?Utf-8?B?R2xlbg==?=
 
Posts: n/a
Default Re: ASP.NET 2.0 Login control
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.DefaultButton = "Login1" and it will not compile. Your
solution would require something like: Panel1.DefaultButton = "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
>
>



=?Utf-8?B?R2xlbg==?=
  Reply With Quote
Old 01-27-2006, 07:47 PM   #4
David Barkol
 
Posts: n/a
Default Re: ASP.NET 2.0 Login control
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.



David Barkol
  Reply With Quote
Old 01-27-2006, 08:08 PM   #5
=?Utf-8?B?R2xlbg==?=
 
Posts: n/a
Default Re: ASP.NET 2.0 Login control
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.
>
>



=?Utf-8?B?R2xlbg==?=
  Reply With Quote
Old 02-04-2006, 01:21 PM   #6
simonjarita
 
Posts: n/a
Default Re: ASP.NET 2.0 Login control
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)Master.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)myLoginControl.FindControl("LoginButton");

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

mainform.DefaultButton = loginbtn.UniqueID;

here's the complete code:

protected void Page_Load(object sender, EventArgs e)
{
myLoginControl.Focus();
HtmlForm mainform = (HtmlForm)Master.FindControl("form1");
Button loginbtn =
(Button)myLoginControl.FindControl("LoginButton");
if (mainform != null && loginbtn != null)
{
mainform.DefaultButton = loginbtn.UniqueID;
}
}

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



simonjarita
  Reply With Quote
Old 05-16-2006, 05:02 PM   #7
MChavarrria
Junior Member
 
Join Date: May 2006
Posts: 1
Thumbs up Thanks a lot
Thanks for share your code this solution works fine!!


MChavarrria
MChavarrria is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
help required in file upload control in asp.net Upmanyu Software 0 03-27-2008 01:51 PM
Nested forms and server-side control in ASP.NET mredelin Software 0 12-20-2007 09:12 PM
ASP.Net 2.0 - Want details view but need control & placement of textboxes etc. daveydave999 Software 0 10-05-2007 04:12 PM
login control in vs2005 nitinnikam Software 0 10-30-2006 08:46 AM
ASP.NET: User Control Events is Not Displaying in a Property Window BabuA Software 0 09-14-2006 05:44 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46