Strongly Typed Data Controls in asp.net 5
Strongly Typed Data Controls
The next release of ASP.NET provides the ability to enable strongly-typed data templates. Specifically, we’ve added the ability to declare what type of data a control is going to be bound to, by way of a new “ModelType” property on data controls. Setting this property will cause two new typed variables to be generated in the scope of the data-bound template expressions: Item and BindItem.
Developers can use these variables in data-binding expressions and get full Intellisense and compile-time checking support. For example, below we’ve set the ModelType on an <asp:repeater> control to be a “Customer” object. Once we do this we can switch from using Eval(“FirstName”) to instead use Item.FirstName to reference the property.
We get full Visual Studio code intellisense when we do so:
For 2-way data-binding expressions, we can also now use the BindItem variable and get the same strongly-typed benefits:
<asp:FormView ID="editCustomer" runat="server">
<EditItemTemplate>
<div>
First Name:
<asp:TextBox ID="firstName" Text='<%# BindItem.FirstName %>' runat="server" />
</div>
<div>
Last Name:
<asp:TextBox ID="lastName" Text='<%# BindItem.LastName %>' runat="server" />
</div>
<asp:Button runat="server" CommandName="Update" />
</EditItemTemplate>
</asp:FormView>
What is WPF ? Why it is used?
WPF is Object Oriented , XAML based.
- It Uses DirectX Engine for rendering GUI
- It do not use GDI 32 programming at all as opposed to Win32 applications
- It do not require more time or cost for graphics, drawing or animation programming
- It is Easy to change resolution unlike win32 application
- It is XAML Friendly.
- It has .NET API that has integrated to XAML (Xtensible Application Markup Language)
- Easily select the Controls unlike Win32 Controls.
- It has the ability to create 3D graphics in windows apps
- It contains Separate API for graphics and animation
- Most powerful Windows UI Framework
It is used for the
- For the better User Interface & the Design
- Customization of Controls
- Integrating Flash, Direct, Win32, Windows Forms
- For Generic consistency professional look (Using Styles like CSS in Web)
WPF Interview Questions
1. What is WPF ? Why it is used?
2. What is XAML?
3. What is Dispatcher Object?
4. What is Dependency Object?
5. What is the architecture of WPF?
6.What is are Types of events and Event Routing or a Routed Event?
7. What is difference between Event Bubbling vs Event Tunneling? When to apply what?
8.What are difference between Win-Forms and WPF?
9. What are different types of Panels in WPF ?Explain them?
10.What is difference between StackPanel, DockPanel, WrapPanel and Grid?
11.What are Primitive Controls and Look Less Controls?
12.What are different important components to know in WPF? Explain them?
13. Why do you think WPF has more power?
14. What is difference between WPF and Web Applications which do you prefer? When to choose what?
15. Is Silverlight part of WPF or subset of WPF? What is difference between WPF and Silverlight
16. What is the class name from which all WPF objects are derived from?
17. How did you create Dependency Object?
18. How did you implement Dependency Property?
19. What is PRISM ? What are its advantages of using it in real time applications?
10. How did you install and implement PRISM in real-time applications?
ASP.NET Validation Server Controls
CompareValidator Compares the value of one input control to the value of another input control or to a fixed value
CustomValidator Allows you to write a method to handle the validation of the value entered
RangeValidator Checks that the user enters a value that falls between two values
RegularExpressionValidator Ensures that the value of an input control matches a specified pattern
RequiredFieldValidator Makes an input control a required field
ValidationSummary Displays a report of all validation errors occurred in a Web page
HTML Server Controls
HtmlAnchor Controls an <a> HTML element
HtmlButton Controls a <button> HTML element
HtmlForm Controls a <form> HTML element
HtmlGeneric Controls other HTML element not specified by a specific HTML server control, like <body>, <div>, <span>, etc.
HtmlImage Controls an <image> HTML element
HtmlInputButton Controls <input type="button">, <input type="submit">, and <input type="reset"> HTML elements
HtmlInputCheckBox Controls an <input type="checkbox"> HTML element
HtmlInputFile Controls an <input type="file"> HTML element
HtmlInputHidden Controls an <input type="hidden"> HTML element
HtmlInputImage Controls an <input type="image"> HTML element
HtmlInputRadioButton Controls an <input type="radio"> HTML element
HtmlInputText Controls <input type="text"> and <input type="password"> HTML elements
HtmlSelect Controls a <select> HTML element
HtmlTable Controls a <table> HTML element
HtmlTableCell Controls <td>and <th> HTML elements
HtmlTableRow Controls a <tr> HTML element
HtmlTextArea Controls a <textarea> HTML element
Introduction to ASP.NET with C#
Asp, which is now more commonly known as Classic Asp was used extensively in 1990's. The idea of creating dynamic pages and linking them with database was the main purpose of classic Asp. Asp used html controls for user interaction. Apart from the good features available in Asp programming, it also lacks in some of the major areas. These areas include clean coding as asp pages were incline pages and all the business logic as well as the interface was coded in a single page. This produces many problem when the code had to be updated or modified. Asp pages also lacked performance and scalability which were fixed in Asp.net. Lets see what Asp.net technology has to offer a developer to build dynamic pages much faster.
Language Options:
Asp.net provides lets you choose the scripting language between javascript and VbScript. This is beneficial for the java programmers as well as the VB programmers since they already have the basic background of the language.
Caching features:
Asp.net also introduces caching features which increases the performance of the application. Caching allows the developer to save the recently used data in a cache variable so that if does not have to spend any time looking for it in the future when anyone requests it.
Use of Controls:
Asp.net provides the developer with several controls to perform basic as well as advanced operations. Controls provided in Asp.net falls under HTML Controls, HTML Server Controls and Web Server Controls.
HTML Controls:
Html controls are the basic controls that are executed on the client machine. These controls include textbox, label , image etc. A simple example of html control can be given by the following code which renders an image.
As you see HTML controls are very easy to use but they don't provide much features. Microsoft decided to introduce HTML Server controls which extends the functionality of simple HTML Controls.
HTML Server Controls:
HTML Server Controls looks exactly like the HTML Controls with one difference that they are executed on the server rather than the client. A simple example of HTML Server controls is given below:
just add a runat server attribute with the image tag.
As you can see that the image tag or control looks exactly like the one that we have previously discussed. But it has an additional attribute which is runat. The runat attribute denotes that this is a HTML Server Control and will be executed on the Server rather than the client.
Note: src attribute in the image tag denotes the path of the image it can be "C:MyDirectorymyImage.jpg"
Asp.net Web Applications:
Asp.net is based on the .NET framework for building web applications. Since Asp.net is a part of the Microsoft. NET Framework it has the ability to take advantage of rich class libraries provided by Microsoft. The question is that why should one use Asp.net and not use classic asp or any other web programming technology. Here are some of the features of Asp.net that makes it the best web application technology.
Web Server Controls
Web Server Controls are the most advanced controls in Asp.net. Each control comes with tons of features that allows the developer to complete the task in less time.Web Server Controls are executed on the Server. Web Server Controls include datagrid control, datalist control, calendar control and many many more.
Special Note:
When dealing with different types of controls one must always remember that when to use which control. If the control will only act as a static entity than you should always use HTML Controls. If the control will be dynamic you should useWeb Server Controls.