简体   繁体   中英

ASP.NET Text Box doesn't get focus when page is redirected from a Silverlight page

I am stuck in a very strange issue that happens in the Chrome browser only .

I have a Silverlight page with a button on it. On clicking that button I want to open an ASPX page with a text box on it having attribute autofocus applied. But whenever I redirect from Silverlight page to ASPX page, the text box is never get focused on Chrome browser. Did anyone face such issue before?

Below are the version information associated

  1. Google Chrome : 41.0.2272.89 m
  2. .NET Framework : 4.5.1
  3. Silverlight : 5.0

Code Snippet Silverlight ( MAIN.XAML File)

    <Grid x:Name="LayoutRoot" Background="White">
        <Button Content="Go to Default page" Click="Button_Click" HorizontalAlignment="Left" Margin="161,131,0,0" VerticalAlignment="Top" Width="156"/>
    </Grid>

Code Snippet Silverlight ( MAIN.XAML.CS File )

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("Default.aspx", UriKind.Relative));
    }

Code Snippet DEFAULT.ASPX page

    <div>
        <asp:TextBox runat="server" ID="txtName" ClientIDMode="Static" autofocus/>
    </div>

Please help

而不是自动对焦,TabIndex =“ 0”可以工作吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM