You are on page 1of 7

LAQ

UNIT 3
Q1 EXPLAIN THE BASIC WINDOWS FORM CONTROL IN C#?
A:Window-based programming (Window Forms) in C# refers to creating graphical user
interface (GUI) applications in the C# programming languag
1.This involves designing windows, dialogs, and forms that contain controls such as
buttons, text boxes, and labels, and writing code to handle user interaction with these
controls.
2.In C#, you can create windows-based applications using the Windows Forms library,
which provides a set of classes that simplify the process of creating and manipulating
graphical elements on the screen.
3.The Visual Studio IDE also provides drag-and-drop tools for designing user interfaces,
which can help speed up the development process.
4.Once you have designed the user interface for your application, you can write code to
handle events such as button clicks, text box changes, and other forms of user interaction.
Some of the most commonly used controls include:
1.Buttons: Used to initiate an action when clicked.
This.button1=new system.windows.forms.button();
Private button button1;
2.Text Boxes: Used to enter and display text.
This.textbox1=new system.windows.forms.textbox();
Private textbox textbox1;
3.Labels: Used to display text or images.
This.label1=new system.windows.forms.label();
Private label label1;
4.Combo Boxes: A drop-down list that allows the user to select from a list of items.
This.combobox1=new system.windows.forms.combobox();
Private combobox combobox1;
5.List Boxes: Used to display a list of items.
This.listbox1=new system.windows.forms.listbox();
Private listbox listbox1;
6.Picture Boxes: Used to display an image.
7.Progress Bars: Used to display the progress of a task.
8.Track Bars: Used to select a value within a range.
9.Tree Views: Used to display a hierarchical structure of items.
10.Date Time Picker: Used to select a date and time.
This.datetimepicker1=new system.windows.forms.datetimepicker();
Private datetimepicker datetimepicker1;
11.Rich Text Box: A text box that supports rich formatting, such as bold, italic, and
underline.
12.Check Boxes: Used to select or deselect an option.
This.checkbox1=new system.windows.forms.checkbox1();
Private checkbox checkbox1;
13.Radio Buttons: Used to select one option from a group of options.
This.radiobutton1=new system.windows.forms.radiobutton1();
Private radiobutton radiobutton1;
14.Panel: Used to group controls together.
15.Group Box: Used to group controls together and provide a caption
Q2 Discuss about the radio buttons properties, methods and events
With suitable program.
A:The RadioButton control in C# is used to present a set of mutually exclusive options to
the user.
2.When several RadioButton controls are placed together, they form a group in which
only one button can be selected at a time.
3.The user can select one option from a group of RadioButton controls, and the control
that is selected is indicated by a small circle in the center of the control. When the user
clicks on a RadioButton control, it becomes checked and all other controls in the same
group become unchecked.
Properties:
●Checked: Gets or sets a value indicating whether the RadioButton control is checked or
not.
●Text: Gets or sets the text displayed next to the RadioButton control.
●Name: Gets or sets the name of the RadioButton control.
●AutoCheck: Gets or sets a value indicating whether the RadioButton control should
automatically change its state when clicked.
●GroupName: Gets or sets the name of the RadioButton group to which the control
belongs.
Methods:
●PerformClick: Simulates a click on the RadioButton control.
●OnCheckedChanged: Raises the CheckedChanged event.
●OnClick: Raises the Click event.
●ToString: Returns a string that represents the current RadioButton control.
Events:
1.CheckedChanged: This event is raised when the Checked property of the RadioButton
control is changed.
2.Click: This event is raised when the RadioButton control is clicked by the user.
3.DoubleClick: This event is raised when the RadioButton control is double-clicked by the
user
LAQ
UNIT 4
Q1:Explain the different ASP.NET Server side controls?
A:
1.Label:It is used to display text on the HTML page.
<asp:labelid=”login” text=”User-id” runat=”server”/>
2.Textbox:It is used to create a text input in the form.
<asp:textbox id=”fname” runat=”server”/>
3.Button:It is used to create a button.
<asp:ButtonID=”Button1” runat=”server” Text=”Submit”/>
4.Linkbutton:It is used to create a button that looks similar to the hyperlink.
<asp:linkbutton id=”linkbutton1” runat=”server”
onclick=”linkbutton1_clicl”>.net</asp:Linkbutton>
5.ImageButton:It is used to create an imagesButton. Here, an image works as a Button.
<asp:imagebutton id=”imagebutton” runat=”server”/>
6.Hyperlink:It is used to create a hyperlink control that responds to a click event.
<asp:HyperLinkID=”HyperLink1” runat=”server” Text=”JavaTpoint”
NavigateUrl=www.javatpoint.com ></asp:HyperLink>
7.DropDownList:It is used to create a dropdown list control.
<asp:dropdownlist id=dropdownlist1” text=”text” datatextfield=”datasourcefield”
runat=”server”/>
8.ListBox:It is used to create a ListBox control like the HTML control.

<asp:listbox id=”listbox 1” rows=”6” width=”100px” runat=”server”/>

9.RadioButton:It is used to create radio button.


<asp:radiobutton id=”radiobutton1” text=”text” runat=”server”/>
10.CheckBox:It is used to create checkbox.
<asp:checkbox id=”checkbox1” text=”text” runat=”server”/>
Q2.Discuss about ASP.NET Applications
A:ASP.NET is a web development framework that allows developers to build dynamic,
data-driven web applications. It was developed by Microsoft and is a popular choice for
building enterprise-level applications due to its scalability and security features. ASP.NET
applications can be developed using either C# or Visual Basic .NET programming
languages.
Here are some of the key features of ASP.NET applications:

1.Server-side scripting: ASP.NET applications are built on top of the .NET framework,
which means that they run on the server-side. This allows developers to build dynamic
web pages that are created in response to user requests.
2.MVC architecture: ASP.NET applications use the Model-View-Controller (MVC)
architecture, which separates the application’s logic, presentation, and data storage
layers. This makes it easier to maintain and modify the application over time.
3.Cross-platform development: ASP.NET applications can be developed on a variety of
platforms, including Windows, Linux, and macOS. This allows developers to use the tools
and platforms that they are most comfortable with.
4.Security features: ASP.NET applications have built-in security features that help protect
against common web application vulnerabilities, such as cross-site scripting (XSS) and SQL
injection attacks.
5.Integration with other Microsoft technologies: ASP.NET applications can easily integrate
with other Microsoft technologies, such as SQL Server, Azure, and Visual Studio. This
makes it easier to build complex, enterprise-level applications that require integration
with other systems.
Q3.What is the use of validation control? List out the different types of
Validation controls available in ASP.NET. Explain the use of the
Controls?
A:Validation controls are an essential part of building any web application as they ensure
that the user inputs are accurate and valid. In ASP.NET, validation controls are used to
check whether the user inputs match certain predefined criteria and to prevent users
from submitting invalid data.
There are several types of validation controls available in ASP.NET, including:
1.RequiredFieldValidator – This control is used to check if a user has entered data into a
field that is required. It can be applied to any input control like a textbox or a dropdown
list.
<asp:RequiredFieldValidatorIDasp:RequiredFieldValidatorID=”user” runat=”server”
ControlToValidate=”username”
ErrorMessage=”Please enter a user name”
ForeColor=”Red”></asp:RequiredFieldValidator>
2.RangeValidator – This control is used to check if a user has entered a value within a
specified range. It can be applied to numeric or date values.
<asp:RangeValidator ID=”RangeValidator1” runat=”server”
ControlToValidate=”uesrInput”
ErrorMessage=”Enter value in specified range” ForeColor=”Red” MaximumValue=”199”
MinimumValue=”101” SetFocusOnError=”True”Type=” Integer”></asp:RangeValidator>
3.RegularExpressionValidator – This control is used to check if a user has entered data
that matches a specific pattern, using regular expressions.
<asp:RegularExpressionValidator ID=”RegularExpressionValidator1”
runat=”server”ControlToValidate=”username”
ErrorMessage=”Please enter valid email”
ForeColor=”Red”ValidationExpression=”\w+([+.’]\w+)@\w+([-.]\w+)\.\w+([-.]\w+)*”>
</asp:RegularExpressionValidator>
4.CompareValidator – This control is used to compare the values of two input controls, to
ensure that they are equal or that one is greater than the other.
< asp:CompareValidator ID=”CompareValidator1” runat=”server”
ControlToCompare=”secondval”
ControlToValidate=”firstval” Display=”Dynamic” ErrorMessage=”Enter valid value”

ForeColor=”Red” Operator=”LessThan” Type=”Integer”></asp:CompareValidator>

5.CustomValidator – This control allows you to create your own custom validation logic,
using server-side code or JavaScript.
< asp:CustomValidator runat=”server” id=”cusCustomTxt”
controltovalidate=”txtCustomValidator”
Onservervalidate=”cusCustomTxt_ServerValidate”
Errormessage=”Lebgth must be 8 or more characters...” / >
Q4.Write a ASP.NET Web application program to demonstrate the use of
RequiredFormValidator control.
A:<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”WebForm1.aspx.cs”
Inherits=”WebApplication1.WebForm1” %>

<!DOCTYPE html>

<html xmlns=http://www.w3.org/1999/xhtml>
<head runat=”server”>
<title></title>
</head>
<body>
<form id=”form1” runat=”server”>
<div>
<asp:TextBox ID=”txtName” runat=”server”></asp:TextBox>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1” runat=”server”
ControlToValidate=”txtName” ErrorMessage=”Please enter a name”
Display=”Dynamic”></asp:RequiredFieldValidator>
<br />
<asp:Button ID=”btnSubmit” runat=”server” Text=”Submit” />
</div>
</form>
</body>
</html>

You might also like