Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-16
7
Medium Priority
?
1,304 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: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
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!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

715 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