setting focus inside a popupcontrolexternder

Hi,

 I need some help with a popupcontrolextender.  I have a popupcontrol extender that pops up a panel with a textbox inside it.  However, when the panel displays, the focus is not set.  I would like to set the focus to the textbox in the panel when the popup is displayed.   I have watched the video and googled extensivelly.  All I found is that the Ajax system is deeper then what initially meets the eye and that I am basically just a novice at this point.  

 If I need to modify the javascript that popupcontrolextender uses, where do I look to find it?  I would rather not do that if possible since I think it will be hard to keep it working as new releases occur.

 Thanks,

Dean

0
eanda9000
8/17/2007 2:32:02 AM
asp.net.ajax_control_toolkit 17816 articles. 1 followers. Follow

4 Replies
391 Views

Similar Articles

[PageSpeed] 4
Get it on Google Play
Get it on Apple App Store

Hi Eanda9000,

My understanding of your issue is that you want to set the TextBox be focused when it is shown by a event.  If I have misunderstood you, please let me know.

eanda9000:
If I need to modify the javascript that popupcontrolextender uses, where do I look to find it?

Please see the Ajax Control Toolkit's source code.

eanda9000:

 I would rather not do that if possible since I think it will be hard to keep it working as new releases occur.

Yes, we can attach a javascript function to PopupControlExtender's shown event. The function will make the TextBox be focused.  Here is the sample which you can wholly copy and run in your project. 

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>PopTest</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        Reminder message:
        <asp:TextBox ID="MessageTextBox" runat="server" Width="200" autocomplete="off" /><br />
        <br />
        <asp:Panel ID="Panel2" runat="server">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </asp:Panel>
        <ajaxToolkit:PopupControlExtender ID="PopupControlExtender1"  runat="server" TargetControlID="MessageTextBox"
            PopupControlID="Panel2" CommitProperty="value" Position="Bottom"/>
            
        <script type="text/javascript" language="javascript">
            function  pageLoad(){
               $find("<%=PopupControlExtender1.ClientID %>")._popupBehavior.add_shown(setFocus);
            } 
            function setFocus(){ 
                $get("<%=TextBox1.ClientID %>").focus();
            } 
        </script>
    </form>
</body>
</html>

 

I hope this help.

Best regards,

Jonathan

 

 

 


Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Jonathan
8/21/2007 6:13:04 AM

This is exactly the type of solution I was hoping for. 

Where does the javascript source code reside?  I do not know where to find it.

 Thanks,

0
eanda9000
8/21/2007 1:21:24 PM

$find("<%=PopupControlExtender1.ClientID %>")._popupBehavior.add_shown(setFocus);

 is producing and error message object not found.   In a debugger I was able to validate that everything to the point of add_shown exists.  Is is possible that _popupBehavior does not have an add_shown method.  Once I have access to the javascript I can determine this myself.

Dean


0
eanda9000
8/21/2007 3:35:40 PM

Hi  Eanda,

this._popupBehavior = $create(AjaxControlToolkit.PopupBehavior, { 'id':this.get_id()+'PopupBehavior', 'parentElement':e }, null, null, this._popupElement);

Line:  49   in PopupControlBehavior.js under PopupControl  directory

add_shown : function(handler) {
        /// <summary>
        /// Add an event handler for the shown event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().addHandler('shown', handler);
    }

Line:  595   in PopupBehavior.js under PopupExtender directory

$find("<%=PopupControlExtender1.ClientID %>")._popupBehavior.add_shown(setFocus);  means you attached a javascript function to its add_shown event.  

All this is include inside the Ajax Control Toolkit 's source code.

Best regards,

Jonathan


Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Jonathan
8/22/2007 1:15:24 AM
Reply:

Similar Artilces:

Trying to set focus to child control inside FormView EditItemTemplate inside a TabPanel
Hey all I have a long page with a bunch of FormViews that I want to have the user click to the EditItemTemplate and have the focus go to that particular FormView in the aspx page. Or if not the focus at least to have the page scroll to where that control is so the user isn't confused  Here is kind of what I am doing  1 <ajaxToolkit:TabPanel runat="server" ID="Panel1" HeaderText="Account Info"> 2 <ContentTemplate> 3 <asp:FormView ID="fvMyName" runat="server" DataSourceID="sqlGetMemberName" ...

superreview granted: [Bug 282098] Accessible focus can get trapped inside of closed popup : [Attachment 174192] When focus is inside popup that becomes hidden, fire focus event for current DOM focus
Brian Ryner (IBM) <bryner@brianryner.com> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 282098: Accessible focus can get trapped inside of closed popup https://bugzilla.mozilla.org/show_bug.cgi?id=282098 Attachment 174192: When focus is inside popup that becomes hidden, fire focus event for current DOM focus https://bugzilla.mozilla.org/attachment.cgi?id=174192&action=edit ...

setting focus inside a datawindow
How do I set focus on a particular column within a datawindow? Reading Help is very beneficial. SetColumn() -- pbm_thisusuallydoesnothelp:-)) Philip Salgannik "J" <j@here.com> wrote in message news:wjkqDEDFAHA.202@forums.sybase.com... > How do I set focus on a particular column within a datawindow? > > > Philip Salgannik <psalgannik@softrax.com> wrote in message news:DmWN$NDFAHA.202@forums.sybase.com... > Reading Help is very beneficial. Philip, Forgive me for overlooking this command and I will forgive you for your m...

Setting the Focus in .net 1.1
Hi I have an online survey where the user will select answers using radio buttons. On the bottom of the page I have a 'previous' and 'next' buttons. I have a bit of javascript which sets the focus when the page is made visible and this works fine, but as soon a radio button is selected the focus, i.e. the black surrounding line of the button, moves to the 'previous' button!In the html the previous button comes before the next button.Why does this happen? Thanks for any insights Davej  The focus should go to the radio button when you click select it. ...

Setting TextBox focus inside UpdatePanel
Hi, I have the code at the bottom of this message defined in a UserControl. It displays a login prompt for a user. There are multiple controles on the page to emulate the XP welcome screen behavour. I.e. it shows all the available users and when you click the user name a password prompt is shown. I am using an update panel to post back to the server and run the required code and show the hidden panel with the password field. My issue is I need the password box when shown to have focus. Simply calling Password.Focus() client side does not work and I am unsure how to include script that is ...

set focus in textbox inside gridview
Hi All, When a checkbox is checked I have to set focus in textbox which is inside the gridview.  Can anybody help me how to do that. Any help will be appreciated. Thanks in advance. You can easily do this on server-side by doing CheckBox.Focus(), but of course you'll have to first find the CheckBox inside the grid by looping through the grid. for example.. for each grv as GridViewRow in me.GridView1 dim checkbox as CheckBox = Ctype(grv.FindControl("chkToFocus"), CheckBox) if (NeedToFocus) then checkbox.Focus() end if Next Another way to do this is by using cus...

Set Focus inside datalist control
Hi all Guys how can i set focus of a textbox which is render inside a datalist control.   i did that by using txt.focus(); but after post back focus comes back to same row .i want to make it jump in another row . any suggestion and help how to do this row count  and after post back set the focus to next row textbox   thx Try this. Get the reference of the control inside the datalist by using the findcontrol method. Next set that the default focus. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you You can also try and have some javascript...

How do you Set focus on Login username in .NET?
I have a Login Authentication control in .NET and I want to set focus on the username when you open the page. Does anyone know how to do this? Whatever the userame control ID is (ex. txtusername.focus())If you get an answer to your question, please mark it as 'Answer' www.lymanlax.com | www.possumslax.com Hi There are two ways:1. ControlName.Focus();2.   <form id="form1" runat="server" defaultfocus="TextBox1" > <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> ...

superreview requested: [Bug 282098] Accessible focus can get trapped inside of closed popup : [Attachment 174192] When focus is inside popup that becomes hidden, fire focus event for current DOM focu
Aaron Leventhal <aaronleventhal@moonset.net> has asked Brian Ryner (IBM) <bryner@brianryner.com> for superreview: Bug 282098: Accessible focus can get trapped inside of closed popup https://bugzilla.mozilla.org/show_bug.cgi?id=282098 Attachment 174192: When focus is inside popup that becomes hidden, fire focus event for current DOM focus https://bugzilla.mozilla.org/attachment.cgi?id=174192&action=edit ...

Focus, focus, focus
As mentioned in my previous post at http://forums.asp.net/t/1337814.aspx  I am just having sooo many problems with setting the focus that it is just driving me haywire.  I'm going to post as little code as possible below here.  If this is insufficient, please let me know.  Essentially, MySetFocus gets called in the onLoad event of the master page.  It checks if all the WebServices are done (counter = 5), if not, it calls itself again after waiting 100 ms.  If so, then it gets the Item name that we'll be focusing on (essentially the ClientID) through a We...

Focus focus focus.........
Ok here is the problem I'm having. I have an evaluation form with a lot of questions on it. When I hit yes or no on a question, the script does a post back. If the answer is no, it posts back displays a box for more info and sets the page focus to it moving to that box. If they hit yes the focus is set to the radio button. The problem I am having is the focused field appears at the bottom of the form, thus causing the person filling out the form to have to scroll. Is there anyway with java script to move that focused field to the top of the page? I'm sure there is something simple, bu...

TabContainer Setting Focus to a control inside the TabPanel
I tried different ways to set the focus in a textbox inside a Tab Panel that was inside a TabContainer, could not get it done, tried with java script, nothing.       <script type="text/javascript">        function RegisteredUser1_TabCliked(sender, e) {            var UserName_Control =  $get('<%=UserName1.ClientID%>');             UserName_Control.focus();        } &n...

Set focus to a control inside a Updatepanel in Atlas
hi,i have several web controls inside a update panel. But i don't know how to set it so that right after my page come back from a callback, it will lost the focus. i tryed .focus() in asp.net, but it doesn't work... help anyone???Even UpdatePanel.update() also not working. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">    protected void srvno_TextChanged(object sender, EventArgs e)    {    &n...

Set focus inside GridView upon edit
I have an editable GridView setup on my ASP.NET 2 web page. When the user clicks "Edit", I want the first editable control in the respective row to gain focus. I have tried setting focus on the GridView, on the edited Row of the GridView, on the Cell in question, all without the desired result. Calling GridView.Focus() simply gives focus to the top left control in the GridView. What can I do? ...

Web resources about - setting focus inside a popupcontrolexternder - asp.net.ajax_control_toolkit

Resources last updated: 12/22/2015 11:06:58 PM