Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-16
7
Medium Priority
?
1,313 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
7 Comments
 
LVL 4

Expert Comment

by:ong-hh
ID: 34913147
0
 
LVL 13

Expert Comment

by:Rahul Agarwal
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses

886 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