Solved

asp.net set default button (enter) as user's control btnLogin

Posted on 2011-02-16
7
1,294 Views
Last Modified: 2012-08-13
trying to set login button (Button1) in user control as default button in the page default.aspx

 
LoginBox.ascx
------------- 
<asp:Button ID="Button1" runat="server" Text="Login" OnClick="Button1_Click" CssClass="mainbutton" />

Open in new window

0
Comment
Question by:doramail05
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:ong-hh
ID: 34913147
0
 
LVL 13

Expert Comment

by:agarwalrahul
ID: 34913196
just put this property in your form tag (in aspx page):

defaultbutton="Button1"

 your form tag looks something like this:

<form id="form1" runat="server" defaultbutton="Button1">
0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 34913519
Hi, Use this javascript for set default button

function clickButton(e, buttonid)
{
var bt = document.getElementById(buttonid);
if (typeof bt == 'object'){
if(navigator.appName.indexOf("Netscape")>(-1)){
if (e.keyCode == 13){
bt.click();
return false;
}
}
if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
{
if (event.keyCode == 13){
bt.click();
return false;
}
}
}
}
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 20

Expert Comment

by:informaniac
ID: 34913538
Can u set the UseSubmitBehavior=true to the button in the usercontrol and check.
0
 
LVL 8

Expert Comment

by:Anurag Agarwal
ID: 34913547
hello doramail05!!


I think i got a better solution fr tht as default button technique won't help !!

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       SetFocus("ClientIDGenerated_button_of_LoginBox.ascx")
    End Sub

to find client ID you just need to drag the LoginBox.ascx in aspx page and see the source code of the page. there u will find the client id (ID) generated for the login button which you want to set as default.
0
 
LVL 1

Accepted Solution

by:
doramail05 earned 0 total points
ID: 34913989
got it already,

Dim _uc As UserControl = DirectCast(Page.FindControl("loginBox1"), UserControl)

        Dim _btnClick As Button = DirectCast(_uc.FindControl("Button1"), Button)

        Form.DefaultButton = _btnClick.UniqueID

Open in new window

0
 
LVL 1

Author Closing Comment

by:doramail05
ID: 34941486
solved already from other post/forum
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question