Tag Archives: .Net Tutorial

Windows 8: Hide Virtual Keyboard Programmatically

The visibility of the virtual keyboard in Windows 8 Metro Style Apps depends on whether a text input enabled control is focused or not:

In the left image the user tapped into a TextBox control. This tap sets the focus on that TextBox and the virtual keyboard appeared. After having entered some Text the user taps the “OK” button and the virtual keyboard hides again due to the loss of focus (right image).

with-keyboard_thumb1    without-keyboard-copy_thumb1

But sometimes there is no Button control to hit after having entered some text and thus the virtual keyboard does not hide and still might cover important parts of the UI. In order to hide the virtual keyboard no matter where the user taps outside the TextBox one could set the focus to a hidden button programmatically.

See the following example:-

XAML Markup:-

 <Grid>
      <Button x:Name="hiddenButton" Opacity="0" />
      <TextBox Width="300" Margin="50" LostFocus="TextBox_LostFocus" />
 </Grid>

 

C# Code Behind:- 

private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
      this.hiddenButton.Focus(Windows.UI.Xaml.FocusState.Pointer);
}

Happy Programming :-)

ASP.NET – .NET Interview Questions and Answers Part-1

1. What is ASP.NET?

ASP.NET is a specification developed by Microsoft to create dynamic Web applications, Web sites, and Web services. It is a part of .NET Framework. You can create ASP.NET applications in most of the .NET compatible languages, such as Visual Basic, C#, and J#. The ASP.NET compiles the Web pages and provides much better performance than scripting languages, such as VBScript. The Web Forms support to create powerful forms-based Web pages. You can use ASP.NET Web server controls to create interactive Web applications. With the help of Web server controls, you can easily create a Web application.

2. In which event are the controls fully loaded?

Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event.

3. How can we identify that the Page is Post Back?

Page object has an “IsPostBack” property, which can be checked to know that is the page posted back.

4. What is the lifetime for items saved in ViewState?

The items saved in ViewState live until the lifetime of the current page expires including the postbacks to the same page.

5. How information about the user’s locale can be accessed?

The information regarding a user’s locale can be accessed by using the System.Web.UI.Page.Culture property.

Skip to toolbar