Home » VB.Net

Ajax Combo Focus


I am having a problem Ajax Combo ,

I have 2 ajax combobox control, and both are independently populated,

if i click on the dropdown button, it shows the list dropdown , without cliking anywhere , if you click on hte other ajax combo dropdown button, the other combo dropdown should hide, but its not happening

Its showing both drop downs

Any help in this is much Appreciated.





11 Answers Found


Answer 1


Could you post the related code?

For more details of Combo, please refer to:http://www.asp.net/ajaxlibrary/act_ComboBox.ashx.


Answer 2

<cc1:ComboBox ID="ddlOffice" CssClass="font10" RenderMode="Block" runat="server"  DropDownStyle="DropDownList" AutoCompleteMode="SuggestAppend" Width="132px">

 <cc1:ComboBox ID="ddlReviewer" CssClass="font10" RenderMode="Block" runat="server" DropDownStyle="DropDownList" AutoCompleteMode="SuggestAppend" Width="132px">


If you click  on the dropdown  button in the ddloffice combo  and directly if you click on the dropdown button  of the ddlReviewer combo  you will see both dropdown listed.





Answer 3


The scenario is not happen on my side. I think there should be no problem  of that. I suggest you checking the ComboBox properties agian at:http://www.asp.net/ajaxlibrary/act_ComboBox.ashx and http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ComboBox/ComboBox.aspx.


Answer 4

So for you once you click  directly on the dropdown  on the other control  , the previously opend dropdown collapsed? and you see only one dropdown shown


I am not able to attach the image, so that i could have shown you the snapshot




Answer 5


Yes, the two ComboBox don't have direct relation. So they will not interaction.


Answer 6


its not working for me, even i have 2 two combobox  dont have any releation, i just clicked on the dropdown  ( that small arrow button  ) and then click on the next combobox's dropdown button ( that small arrow button )  without clicking anywhere.




Answer 7


OK. Then could you send you project to me(my email)? And I will test on my side. 


Answer 8

Email address please, 


Answer 9


I have sent a email to you. 


Answer 10


Did you receive my email,

Please let me know if you need anything else




Answer 11


I have received your email. And reply to you attach the solution just now. The code I add in your application as below:

    <script type="text/javascript">
        function pageLoad() {

        function onshowing() {


Search for  Ajax Combo Focus


When my from opens i am trying to get the new record in a sub form to set focus. My sub form is subAdditionChargeChild and my combo box i want to set focus to is cbChargeID

Any help please.........Bob


I have combo/dropdown boxes in my web page and once I transulate the page by using ajax api then I am loosing my selection and its always select first item in the combo/dropdown box.



Venkat Nayineni


 how to store the values(code,name)  from sql database in ajax combo box  4.0  framework.....and how to write the class file any body tell me ...................

thanks and advance



i have an issue with the ajax toolkit combo box: i have 2 combos 1 for countries the second is for governorates and the governorates get filled with certain values when a country is selected ,the user can insert new values in both combos what happens is when i select a country that already exists in the combo the governorates get filled right and no problem happens but when i insert a new value in countries combo this error in javascript happens: Error: Sys.WebForms.PageRequestManagerServerErrorException: 'lstGovernorate' has a SelectedIndex which is invalid because it does not exist in the list of items.Parameter name: value Error: Sys.WebForms.PageRequestManagerServerErrorException: 'lstGovernorate' has a SelectedIndex which is invalid because it does not exist in the list of items.




<asp:ComboBox Id="lstCountry" meta:resourcekey="lstCountryResource1" 


                                runat="server" oniteminserted="lstCountry_ItemInserted"










<asp:ComboBox ID="lstGovernorate" runat="server" 


                                meta:resourcekey="lstGovernorateResource1" Enabled="False"
















code behind:

protected void lstCountry_ItemInserted(object sender, ComboBoxItemInsertEventArgs e)


cntryService = new CountryService(CompanyId); Countries AddedCountry = cntryService.AddCountry(e.Item.Text.Trim()); e.Item.Value = AddedCountry.CountryId.ToString(); lstGovernorate.Enabled = true; lstGovernorate.Items.Clear(); lstGovernorate.ClearSelection(); lstGovernorate.Items.Add(new ListItem("Please select a governorate", "-1"));



protected void lstCountry_SelectedIndexChanged(object sender, EventArgs e)


if (lstCountry.SelectedValue == "-1") { ClearLstGovernorate(); } else { lstGovernorate.Enabled = true; int countryId = Convert.ToInt32(lstCountry.SelectedValue); fillGovernoratesLst(CompanyId, countryId); //ClearLstCity();



the error happens right after item inserted event is completed

need help urgently please


Hiii.. Everybody

How to set the focus on textbox when requiredfield validator error mesage comes to action inside the ajax tabcontrol.The ajax tabcontrol is having 5 tabs.The submit button is in 5th tab .I have reqiredfield validator for textbox  in 1st tab.I want to set the focus on textbox if validation fails.Is it possible to get without postback????

Is there anyone can help me out ????

Thanks in advance


Hello Friends,

In my .aspx page I use Ajax Html editor.... and Currently I need to focus the Editor if the Editor's Content is empty.....

For That I use the following js functions in my Page.....

<script type="text/javascript">
        function pageLoad() {
            if (typeof window.ValidatorGetValue == "function") {
                if (typeof window.ValidatorGetValue_saved != "function") {
                    window.ValidatorGetValue_saved = window.ValidatorGetValue;
                    window.ValidatorGetValue = function (id) {
                        var component = $find(id);
                        if (component != null) {
                            if (AjaxControlToolkit.HTMLEditor.Editor.isInstanceOfType(component)) {
                                component.get_editPanel()._contentPrepared = false;
                                var content = component.get_content();
                                if (content == "<br />") content = "";
                                //alert("Type Content");
                                return content;
                        return window.ValidatorGetValue_saved(id);

The js function works correctly in i.e. browser but in Mozila it can not work properly....

Give Ur Ideas ...... about focus the editor with require field validator


I am doing when the form  loads up


DataGridViewComboBoxColumn ComboTextCol = new DataGridViewComboBoxColumn();
            ComboTextCol.Headertext = "some";
            ComboTextCol.DataSource =  GetEmployees().Select(e => new { Name = e.LastName + " ," + e.FirstName, ID = e.EmployeeID }).ToList();
            ComboTextCol.ValueMember = "ID";
            ComboTextCol.DisplayMember = "Name";

I tried this too datagrid.Columns.Add(ComboTextCol).

GetEmployees gives employee data

I see the column but  not the the data...??

Have a hierarchical list of data that the user can select values from, however they have to select the second item from a list that is restricted based on the entry selected in the first combo box.


Item a

item 1 item 2 item 3

Item b

item 1 item 4 item 5 item 6

Item C

item 2 item 3 item 5 item 6

Does anyone have any ideas about how to go about populating the first and second combo boxes so that this would work?


We use fancy focus indicators in our controls, and since our controls may change their outline dramatically during runtime, we place triggers on "IsKeyboardFocused" property to shape our focus indicators.

The problem is that when such a method is used, the focus indicator is drawn when user clicks on the control. The expected behaviour would be that the focus indicator is drawn only when focus is received via keyboard. We tried placing triggers on other properties (IsFocused, etc.) but it did not work.

In summary, how can one draw a "focus indicator" only when control receives focus via keyboard, not when 'via mouse' (without using FocusVisualStyle)? Or does any alternative approach exists?

The solution should be very simple, so probably we are missing something. Does anyone have any idea?


Thanks in advance,



When my hidden CDHTMLDialog navigates to certain pages with focus commands (e.g. element.focus() and window.focus()) the keyboard focus is stolen from the currently focused window, even when the CDHTMLDialog set NOACTIVATE, hidden and disabled:

	CDHtmlDialog::Create(IDD_DHTMLDIALOG_DIALOG, pParent);
	// Tool windows do not appear in taskbar etc.
	// Never wanna see this window

Strangely enough, focus is NOT stolen when the IE window that created this CDHTMLDialog has more than a single tab open. This effect is strange especially considering that I created the CDHTMLDialog without a parent:
	// Creates CWnd and makes it wrap the IE window. MFC API requries CWnd.
	CWnd parent;

	// Actually creates the Window

	//Parent is on the stack. Therefore, its Destructor will be called, and in its turn will destroy its corresponding window
	//(i.e the IE window). Thus, we detach before stack is closed.

I tried to change the script using put_innerHTML, but it didn't work because I need to wait for DocumentComplete to get the HTML and its too late to change it by then.
I tried to switch the document to design mode so that it doesn't run javascript, but then OTHER javascript that I DO want to run, doesn't.
I even tried to hook WM_ACTIVATE, WM_ACTIVATEAPP, WM_SETFOCUS and on any of them reset focus back to the previous window from which it was stolen, but I always got NULL for it.

What can I do? This is driving me crazy for a while now...

I have a popup containing a TreeView and when the popup is opened I call Tree.Focus() to set the focus on the contained tree.


This works fine as long as the focus is currently on a WPF control, but if I have a WinForm (or MFC form) hosted and the focus is in either of those then the focus does not get set to the treeview, and even mouse and keyboard input on the tree does not work.

I have of tried with Tree.SetFocus(), Keyboard.Focuse(Tree) and FocusManager.SetFocusedElement(), but neither works.


Any idea how to ‘force’ the focus from the WinForm on to the TreeView?




I have a MaskedEditExtender with Mask="(999) 999-9999".

Now my problem is, if someone goes into the textbox and enters


Then they leave the textbox, and then see that they forgot to enter the area code, if they go back in there to enter the area code, it starts overwritting the other numbers instead of just adding to them. 


Hi All,

I have been writting an WPF application which allows enduser navigating to controls which being bound to an invalid data by clicking on buttons named "Goto Prev Err" and "Goto Next Err". The implementation was written in codebehind by calling Focus method. However the rectangle focus is invisible when a control gets focus via either one of two upon buttons. I tried moving the focus around controls in my view via pressing the "TAB" and I could see that rectangle.

Do you guys have any ideas about that ??? I do appreciate.


var control2Focus = _controls.FirstOrDefault(item => this.IsErrorFile(item) && callback.Invoke((int)item.Key));

if (control2Focus != null) {
    _currErrPos = (int)control2Focus.Key;
    // (control2Focus.Value as Control).Focus();
    Keyboard.Focus(control2Focus.Value as Control);



hello all,

the reason i posted this question is that i just added ajax toolkit in my visual studio 2005 and i installed  ajax web extension version 1;

downloaded from microsoft website named "ASPAJAXExtSetup" but when i added ajax object in my web form i ve gotten this error:

"Error 1: Indirect reference is being made to assembly System.Web.Extensions version, which contains 'AjaxControlToolkit.CalendarExtender'. This Project references a prior version of System.Web.Extensions version 1.0.61025.0. To use 'AjaxControlToolkit.CalendarExtender', you must replace the reference to System.Web.Extensions with version or higher.

 C:\inetpub\wwwroot\AJAXEnabledWebSite1\Default.aspx 1 1 C:\...\AJAXEnabledWebSite1\"

is there any option to upgrade ajax web extension version 1 to upper without installing visual studio 2008 and .net 3.5? or any other solution ?

thank you so much


Dear Friends

I have a problem

condition : server = asp.net FW3.5 .... Client = just and just htmls (no server control /no runat ="server" att)

i open a ajax request from browser and that is ok


1. in case above  a page_load happend on server we all know that, but i cant determine is it asynchorus load or normal load

2. as response of that AJAX call i can't use response.write() cause it will redraw entire page not just a portion

In Litle Details: suppose i there is a <div id = ....> on client page, i just need to send a table, after that javascript will put that under the div.

and response write can't do this cause it send xml for entire page not for just tha table,

So friends Please Help



So I am playing around with a user control that I created that adds some functionality to a SPList. I have scoured the web looking for a way to get a web part that had a gridview with custom buttons that is bound to certain Items in a sharepoint list. I found Smart Parts and created an Ajax enabled User Control. the problem is that the label is updating but the gridview is not. and on a site note how can I format the Time on Board column to not include milliseconds(the fields are showing up like '1.02:48:31.8633636') i just want 1.02:48 and maybe the 31:

here is my ascx:

<%@ControlLanguage="C#"AutoEventWireup="true"CodeBehind="AlertControlWebPart.ascx.cs"Inherits="AlertControlWebPart.AlertControlWebPart, AlertControlWebPart, Version=, Culture=neutral, PublicKeyToken=8e949bef56f67b52"%><%@RegisterTagPrefix="SharePoint"Namespace="Microsoft.SharePoint.WebControls"Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%><div><asp:TimerID="Timer1"runat="server"OnTick="Timer1_Tick1"Interval="10000"></asp:Timer></div><center><asp:LabelID="lblErrorStatus"runat="server"ForeColor="Red"></asp:Label></center><asp:UpdatePanelID="UpdatePanel1"runat="server"><Triggers><asp:AsyncPostBackTriggerControlID="Timer1"EventName="Tick"/></Triggers><ContentTemplate><asp:LabelID="lblRefresh"runat="server" Text=""></asp:Label><asp:GridViewID="gvAlerts"runat="server"AutoGenerateColumns="False"AllowSorting="True"OnSorting="gvAlerts_Sorting"HorizontalAlign="Left"UseAccessibleHeader="False"OnRowDataBound="gvAlerts_RowDataBound"PageSize="5"OnSelectedIndexChanged="gvAlerts_SelectedIndexChanged"CellPadding="4"ForeColor="#333333"GridLines="None"EnableSortingAndPagingCallbacks="True"><FooterStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/><PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"/><SelectedRowStyleBackColor="#D1DDF1"Font-Bold="True"ForeColor="#333333"/><HeaderStyleBorderStyle="Solid"BorderWidth="1"BackColor="#507CD1"Font-Bold="True"ForeColor="White"></HeaderStyle><RowStyleBackColor="#EFF3FB"/><Columns><asp:TemplateFieldShowHeader="False"><ItemTemplate><asp:ButtonID="btnAck"runat="server"Text="Ack"OnClick="AckAlert_Click"/><asp:ButtonID="btnCaseCreation"runat="server"Text="Case"OnClick="CaseCreation_Click"/></ItemTemplate></asp:TemplateField><asp:BoundFieldDataField="Site"HeaderText="Site"ControlStyle-Font-Bold="true"SortExpression="Site"ItemStyle-HorizontalAlign="Left"><ControlStyleFont-Bold="True"/><ItemStyleHorizontalAlign="Left"/></asp:BoundField><asp:BoundFieldDataField="Computer"HeaderText="Computer"SortExpression="Computer"ItemStyle-HorizontalAlign="Left"><ItemStyleHorizontalAlign="Left"></ItemStyle></asp:BoundField><asp:BoundFieldDataField="Message"HeaderText="Message"SortExpression="Message"ItemStyle-HorizontalAlign="Left"><ItemStyleHorizontalAlign="Left"></ItemStyle></asp:BoundField><asp:BoundFieldDataField="Response Code"HeaderText="RC"SortExpression="Response Code"ItemStyle-HorizontalAlign="Left"><ItemStyleHorizontalAlign="Left"/></asp:BoundField><asp:BoundFieldDataField="Event Date"HeaderText="Event Date"SortExpression="Event Date"ItemStyle-HorizontalAlign="Left"><ItemStyleHorizontalAlign="Left"/></asp:BoundField><asp:BoundFieldDataField="Time on Board"HeaderText="Time on Board"SortExpression="Time on Board"ItemStyle-HorizontalAlign="Left"><ItemStyleHorizontalAlign="Left"/></asp:BoundField></Columns><EditRowStyleBackColor="#2461BF"/><AlternatingRowStyleBackColor="White"/></asp:GridView></ContentTemplate></asp:UpdatePanel>



I am getting the following error:


Server Error in '/Trial' Application.
The TargetControlID of 'innerAccordian1_AccordionExtender' is not valid. A control with ID 'innerAccordian1' could not be found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The TargetControlID of 'innerAccordian1_AccordionExtender' is not valid. A control with ID 'innerAccordian1' could not be found.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: The TargetControlID of 'innerAccordian1_AccordionExtender' is not valid. A control with ID 'innerAccordian1' could not be found.]
   System.Web.UI.ExtenderControl.RegisterWithScriptManager() +430
   System.Web.UI.ExtenderControl.OnPreRender(EventArgs e) +45
   AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) +52
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4774

Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053


.aspx file contains following code:
<cc1:Accordion ID="Accordion1" runat="server" SelectedIndex="-1"                    
                   FadeTransitions="false" FramesPerSecond="40" 
                    TransitionDuration="250" AutoSize="None" 
                    RequireOpenedPane="false" SuppressHeaderPostbacks="true" >
.aspx.cs file contains:

protected void Page_Load(object sender, EventArgs e)
        for (int i = 1; i <= 5; i++)
            Label lblHeader = new Label();
            lblHeader.ID = "lblHeader" + i.ToString();
            lblHeader.Text = "<a href='' onclick='return false;'> First Level (" + i.ToString() + ")</a>";
            Accordion innerAccordian = new Accordion();
            AccordionPane accp = new AccordionPane();
            accp.ID = "accp" + i.ToString();
            for (int j = 1; j <= 5; j++)
                AccordionPane innnerAccp = new AccordionPane();
                innnerAccp.ID = "innerAccp" + j.ToString();
                innerAccordian.ID = "innerAccordian" + j.ToString();
                innerAccordian.FadeTransitions = false;
                innerAccordian.FramesPerSecond = 40;
                innerAccordian.SuppressHeaderPostbacks = false;
                innerAccordian.RequireOpenedPane = false;
                Label innerlblHeader = new Label();
                innerlblHeader.ID = "innerlblHeader" + j.ToString();
                innerlblHeader.Text = "<a href='' onclick='return false;'> Second Level (" + j.ToString() + ")</a>";
                for (int k = 1; k <= 5; k++)
                    LinkButton innerLnkButton = new LinkButton();
                    innerLnkButton.ID = "innerLnkButton" + k.ToString();
                    innerLnkButton.Text = "Third Level (" + k.ToString() + ")<BR />";
                    innerLnkButton.Click += new EventHandler(hyp_Click);



Looks like there aren't a lot of users using the Ajax Control Toolkit 40412 and the Microsoft Microsoft Ajax CDN because I can't find any information on how to get the MicrosoftAjax.js and MicrosoftAjaxWebForms.js files to be linked to the CDN.

First issue:

Ajax Control Toolkit 40412 seems to be using its own customized version of MicrosoftAjax.js and MicrosoftAjaxWebForms.js.  Toolkit's version is 4.1.40412.2, while the version that come with ASP.NET Ajax 4 is 4.0.30205.0.  By default when using the toolkit the version is swapped to the toolkit's version.  While the ASP.NET Ajax 4 version is hosted on the CDN (http://www.asp.net/ajaxlibrary/CDNAjax4.ashx) the version with the Toolkit is not (http://www.asp.net/ajaxlibrary/CDNACT40412.ashx), which doesn't make any sense because all the other files are hosted.  Therefore, a CDN version of MicrosoftAjax.js and MicrosoftAjaxWebForms.js is UNAVAILABLE when using the Ajax Control Toolkit 40412.

Second Issue:

Why not use the ASP.NET Ajax 4 version of the the MicrosoftAjax.js, after all its version 4.  The version can be swapped out by adding a Script Resource Mapping to the Application_Start event in the Global.asax.cs.

     void Application_Start(object sender, EventArgs e)
            ScriptManager.ScriptResourceMapping.AddDefinition("MicrosoftAjax.js", new ScriptResourceDefinition
                  Path = "~/Scripts/MicrosoftAjax.js",
                  DebugPath = "~/Scripts/MicrosoftAjax.debug.js",
                  CdnPath = "http://ajax.microsoft.com/ajax/4.0/1/MicrosoftAjax.js",
                  CdnDebugPath = "http://ajax.microsoft.com/ajax/4.0/1/MicrosoftAjax.debug.js"

However, when the version is changed to the ASP.NET Ajax 4 version the following error is given:

"AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll."

It doesn't matter if you are using the ToolkitScriptManager or ScriptManager you will always get this error when not using the version of MicrosoftAjax.js that comes with the AjaxControlToolkit.

So how can one use the Microsoft Ajax CDN for the MicrosoftAjax.js and MicrosoftAjaxWebForms.js with ASP.NET Ajax 4 & Ajax Control Toolkit 40412?

One other note.  The new attribute EnableCdn="true" is of course rendered completely useless when using the Ajax Control Toolkit because the idea is that the MicrosoftAjax.js and MicrosoftAjaxWebForms.js files would then be linked by references to the CDN.  This does not happen with the Toolkit because as described the Toolkit replaces the those files with its own.  I was very surprised to find out that all my excitement about having CDN support was made void when I included the Toolkit in my project.

Thanks in advance for any help in solving this issue,



Dear all,

I need your hep with this issue. I am usng Access 2007. I need to populate a combo box based on the selection of another combo box.

The master combo box or the controler ombo box is named KPI. I have put in the After Update event :

Private Sub Combo_KPI_AfterUpdate()



End Sub

The second combo box controlled has a query :

WHERE (((PROBLEMS_TYPES.KPI)=[Forms]![Form_KPI]![Combo_KPI]))


At runtime, I am always prompted for enter parameter value for the master combo box in order to poulate the second combo box. Can someone help me please


Hi guys I am new to vb.net 2008 and was wondering how do i select from a data grid view combo. The first combo contains my item codes. I want to select an item code and it automatically sets the Description in the other combo or vice versa. I have read some of the articles but getting stuck and failing to grasp the concept. I know there us a simple way of doing this. Please Help

<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure