This is a migrated thread and some comments may be shown as answers.

[Solved] set focus combobox

0 Answers 37 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Francois
Top achievements
Rank 1
Francois asked on 17 Nov 2011, 10:01 AM
Hallo, I'm using the following code and I'm trying to set focus on the combobox.
The code does not work. Any help?

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Granite.WebApp.Controllers.CustomTakeOnModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>TakeOn</title>
    <script language="javascript" type="text/javascript">
        setTimeout(
function setfocus() {
            var comboBox = document.getElementsByName("ConfirmationToPrint");
            var input = comboBox.get_inputDomElement();
            input.focus();
        }
        , 1);

</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm("Confirmation", ViewContext.RouteData.Values["controller"].ToString()))
       {%>
            <img src="<%= Url.Content("~/Content/Images/Previous.gif")%>" alt="prev" />
            <a href="../Home.aspx"><img src="<%= Url.Content("~/Content/Images/Home.gif")%>" /></a>
            <input type="image" img src="<%= Url.Content("~/Content/Images/Next.gif")%>" value="Next" />

        <%= Html.ValidationSummary() %>
        <div class="success">
            <%: TempData["Confirmation"]%>
        </div>

        <fieldset >
            <legend><h3>Bundle</h3></legend>
            <label>Confirmation</label>
            <div><%= Html.Telerik().ComboBox()
                    .Name("ConfirmationToPrint").OpenOnFocus(true)
                    .BindTo(new SelectList(Model.ConfirmationToPrint, ""))
                    .Effects(effect => effect.Slide())
                    .HtmlAttributes(new { onFocus = "this.style.backgroundColor='#F90'" })
    %></div>  

        </fieldset>
    <% } %>
</asp:Content>
Tags
ComboBox
Asked by
Francois
Top achievements
Rank 1
Share this question
or