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

x
?
Solved

ASP.net AJAX Modal Popup Login Box Default Button and Focus

Posted on 2012-03-29
2
Medium Priority
?
1,923 Views
Last Modified: 2012-05-23
Hi All,

I have an asp:LoginStatus control that is the target conrol ID for a modal popup extender.  The modal popup has an asp:login control inside the panel with two text boxes and two buttons.

1. txtUsername
2. txtPassword
3. LoginButton
4. CancelButton

I am having trouble setting the default button and the initial focus when the modal is shown.  

All I need to accomplish is the following:

After the modal.show function is called...
1.  Set focus to the username textbox.
2.  Call the server side click event for the login button when the Enter button is pressed.

I have tried setting the default button of the panel, but that gave me an error stating that I needed to use a control of type iButton.

I tried setting the OkControlID using the clientID of the username, that seemed to do nothing.  

Currently, when you press the enter button when the popup is shown, the popup disappears.

Please Help....I don't know why this is so dificult for me....
0
Comment
Question by:dtechfish
2 Comments
 
LVL 13

Accepted Solution

by:
Rahul Agarwal earned 1500 total points
ID: 37785755
for Setting Default button:

<script type="text/javascript">

        function pageLoad() {
            $find("MPE").add_shown(function() { $get('btnClose').focus(); });
        }
    </script>

Reference:

http://forums.asp.net/t/1381468.aspx/1



for setting focus on text box in Modal Popup:

ScriptManager.RegisterStartupScript(    this,
                                                this.GetType(),
                                                "FocusScript",
                                                "setTimeout(function(){$get('" + btnErrorClose.ClientID + "').focus();}, 100);",
                                                true);

Reference:

http://forums.asp.net/p/1111803/4078130.aspx#4078130
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

824 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