Partial
Class test
Inherits System.Web.UI.UserControl
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles DropDownList1.SelectedIndexChanged
Page.ClientScript.RegisterStartupScript(
Me.GetType(),
"foc", "document.getElementById('" + DropDownList2.ClientID +
"').focus();",
True)
End Sub
Protected
Sub Page_Load(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles Me.Load
End Sub
vasanth.kuma...
Contributor
5324 Points
1041 Posts
Re: DropDownList Focus is Lost!!!
Mar 01, 2008 05:58 AM|LINK
Hi,
its working nicely for me.... please find the full test code here....
test.master.vb
<%
@ Master Language="VB" CodeFile="test.master.vb" Inherits="test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
html xmlns="http://www.w3.org/1999/xhtml" ><
head runat="server"> <title>Untitled Page</title></
head><
body> <form id="form1" runat="server"> <div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form></
body></
html>Test.ascx
<%
@ Control Language="VB" AutoEventWireup="false" CodeFile="test.ascx.vb" Inherits="test" %><
asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"> <asp:ListItem>one</asp:ListItem> <asp:ListItem>two</asp:ListItem> <asp:ListItem>thre</asp:ListItem> <asp:ListItem>four</asp:ListItem></
asp:DropDownList><br /> <br /><
asp:DropDownList ID="DropDownList2" runat="server"> <asp:ListItem>one</asp:ListItem> <asp:ListItem>tow</asp:ListItem> <asp:ListItem>three</asp:ListItem></
asp:DropDownList>test.ascx.vb
Partial Class test Inherits System.Web.UI.UserControl Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChangedPage.ClientScript.RegisterStartupScript(
Me.GetType(), "foc", "document.getElementById('" + DropDownList2.ClientID + "').focus();", True) End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End SubEnd
ClassDefault2.aspx
<%@ Page Language="VB" MasterPageFile="~/test.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" title="Untitled Page" %><%
@ Register Src="test.ascx" TagName="test" TagPrefix="uc1" %><
asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <uc1:test ID="Test1" runat="server" /></
asp:Content>please check this.... can you post your code....
Software Engineer.