![]() |
|
|
|
#1 |
|
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==?= |
|
|
|
|
#2 |
|
Posts: n/a
|
Try placing it within a Panel control and setting the DefaultButton
attribute. David Barkol www.neudesic.com David Barkol |
|
|
|
#3 |
|
Posts: n/a
|
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==?= |
|
|
|
#4 |
|
Posts: n/a
|
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 |
|
|
|
#5 |
|
Posts: n/a
|
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==?= |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|
|
|
#7 |
|
Junior Member
Join Date: May 2006
Posts: 1
|
Thanks for share your code this solution works fine!!
MChavarrria |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |