Awp Unit 5 - 23458535 - 2023 - 11 - 22 - 12 - 24
Awp Unit 5 - 23458535 - 2023 - 11 - 22 - 12 - 24
online
More Academy
ADVANCED WEB
PROGRAMMING
SEM : V
SEM V: UNIT 5
Page 1 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Q1. What is XML? List the various XML classes. (Nov 2019) (Nov 2022)(Apr 2023)
Or
What is XML? What are its basic characteristics
Extensible Markup Language (XML) stores and transports data. If we use a XML file to store
the data then we can do operations with the XML file directly without using the database. The
XML format is supported for all applications.
It is independent of all software applications and it is accessible by all applications. It is a very
widely used format for exchanging data, mainly because it's easy readable for both humans and
machines. If we have ever written a website in HTML, XML will look very familiar to us, as it's
basically a stricter version of HTML. XML is made up of tags, attributes and values and looks
something like this:
<?xmlversion="1.0"encoding="utf-8"?>
<EmployeeInformation>
<Details>
<Name>Richa</Name>
<Emp_id>1</Emp_id>
<Qualification>MCA</Qualification>
</Details>
</EmployeeInformation>
XML Classes:
ASP.NET provides a rich set of classes for XML manipulation in several namespaces that start
with
System.Xml. The classes here allow us to read and write XML files, manipulate XML data in
memory, and even validate XML documents.
The following options for dealing with XML data:
XmlTextWriter
The XmlTextWriter class allows us to write XML to a file. This class contains a number of methods and
properties that will do a lot of the work for us. To use this class, we create a new XmlTextWriter object.
XmlTextReader
Reading the XML document in our code is just as easy with the corresponding XmlTextReader
class. The XmlTextReader moves through our document from top to bottom, one node at a time.
We call the Read() method to move to the next node. This method returns true if there are more
nodes to read or false once it has read the final node.
XDocument
The XDocument class contains the information necessary for a valid XML document. This includes an
XML declaration, processing instructions, and comments. The XDocument makes it easy to read and
navigate XML content. We can use the static XDocument.Load() method to read XML documents from
a file, URI, or stream.
Page 2 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Following C# code is saving all the user input values in XML file.
protected void Button1_Click(object sender, EventArgs e)
{
XmlTextWriter writer = null;
try
{
string filePath = Server.MapPath("~") + "\\Product.xml";
writer = new XmlTextWriter(filePath, System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.WriteComment("Created On: " + DateTime.Now.ToString("dd-MMM-yyyy"));
writer.WriteComment("===============================");
writer.WriteStartElement("Product");
writer.WriteAttributeString("ProductID", TextBox1.Text);
writer.WriteElementString("ProductName", TextBox2.Text);
writer.WriteElementString("ProductQuantity", TextBox3.Text);
writer.WriteElementString("ProductPrice", TextBox4.Text);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
Response.Redirect("Product.xml");
}
catch (Exception ex){ }
}
Page 3 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Reading the XML document in our code is just as easy with the corresponding XmlTextReader
class. The XmlTextReader moves through our document from top to bottom, one node at a time.
Example:
TernTenders.xml
<?xml version="1.0" encoding="utf-8" ?>
<Tenders>
<Ravina>
<BillNo>1</BillNo>
<PageNo>10</PageNo>
<Activity>Metals</Activity>
</Ravina>
<Ravina>
<BillNo>2</BillNo>
<PageNo>20</PageNo>
<Activity>Formworks</Activity>
</Ravina>
< Ravina>
<BillNo>3</BillNo>
<PageNo>30</PageNo>
<Activity>SiteWorks</Activity>
</ Ravina>
</Tenders>
ASPX Page:
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
<asp:DropDownList ID="DropDownList1BillNo" runat="server"></asp:DropDownList>
Code behind Page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDataToGridview();
}
protected void BindDataToGridview()
{
XmlTextReader xmlreader = new
Page 4 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
XmlTextReader(Server.MapPath("~/App_Data/TernTenders.xml"));
DataSet ds = new DataSet();
ds.ReadXml(xmlreader);
xmlreader.Close();
if (ds.Tables.Count != 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
DropDownList1BillNo.DataSource = ds;
DropDownList1BillNo.DataTextField = "BillNo";
DropDownList1BillNo.DataValueField = "BillNo";
DropDownList1BillNo.DataBind();
DropDownList2PageNo.DataSource = ds;
DropDownList2PageNo.DataTextField = "PageNo";
DropDownList2PageNo.DataValueField = "PageNo";
DropDownList2PageNo.DataBind();
DropDownList3Activity.DataSource = ds;
DropDownList3Activity.DataTextField = "Activity";
DropDownList3Activity.DataValueField = "Activity";
DropDownList3Activity.DataBind();
}
}
Page 5 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
The XDocument class contains the information necessary for a valid XML document. This
includes an XML declaration, processing instructions, and comments. The XDocument makes it
easy to read and navigate XML content. We can use the static XDocument.Load() method to
read XML documents from a file, URI, or stream.
Example:
TernTenders.xml
<?xml version="1.0" encoding="utf-8" ?>
<Tenders>
<Ravina>
<BillNo>1</BillNo>
<PageNo>10</PageNo>
<Activity>Metals</Activity>
</Ravina>
<Ravina>
<BillNo>2</BillNo>
<PageNo>20</PageNo>
<Activity>Formworks</Activity>
</Ravina>
< Ravina>
<BillNo>3</BillNo>
<PageNo>30</PageNo>
<Activity>SiteWorks</Activity>
</ Ravina>
</Tenders>
ASPX Page:
<asp:Button ID="ReadXmlUsingXMLDocument" runat="server"
Text="ReadXMLDataUsingXMLDocument" OnClick="ReadXmlUsingXMLDocument_Click" />
<asp:ListBox ID="ListBox2" runat="server" Height="500px" Width="500px"></asp:ListBox>
Code behind Page
protected void ReadXmlUsingXMLDocument_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/App_Data/TernTenders.xml"));
XmlNodeList elemList = doc.GetElementsByTagName("Activity");
for (int i = 0; i < elemList.Count; i++)
{
Page 6 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
ListBox2.Items.Add(elemList[i].InnerXml);
}
}
The XElement class represents an XML element in System.Xml.XLinq. XElement loads and
parses XML. It allows us to remove lots of old code and eliminate the possibility of bugs and
typos. The XAttribute class represents an attribute of an element. XElement.Save method saves
the contents of XElement to a XML file.
Example:
Authors.xml
<?xml version="1.0" encoding="utf-8" ?>
<Authors>
<Author Name="Mahesh Chand">
<Book>GDI+ Programming</Book>
<Cost>$49.95</Cost>
<Publisher>Addison-Wesley</Publisher>
</Author>
<Author Name="Mike Gold">
<Book>Programmer's Guide to C#</Book>
<Cost>$44.95</Cost>
<Publisher>Microgold Publishing</Publisher>
</Author>
<Author Name="Scot t Lysle">
<Book>Custom Controls</Book>
<Cost>$39.95</Cost>
<Publisher>C# Corner</Publisher>
</Author>
</Authors>
Code Behind
XElement allData = XElement.Load(Server.MapPath("~/App_Data/ Authors.xml")
if (allData != null)
{
IEnumerable<XElement> authors = allData.Descendants("Author");
foreach(XElement author in authors)
Response.Write ((string) author);
}
Page 7 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
The validation of an Xml input File could occur at various instances of processing as mentioned below:
using a schema file
In the Database Code for validating against business rules.
All Xml code can be considered as categorically correct if they are well-formed and valid xml files.
Well-formed
The XML code must be syntactically correct or the XML parser will raise an error.
Valid
If the XML file has an associated XML Schema, the elements must appear in the defined structure and
the content of the individual elements must conform to the declared data types specified in the
schema.
Validation of Xml Files can be achieved through the use of various Technologies ex. Visual Studio
Net. Also, there are many on-line Tools available for validating an input .xml File. Few of them
are mentioned below:
Xml Schema Validation
An Xml File is generally validated for its conformance to a particular schema. The Xml schema
file usually is a XML Schema definition language (XSD). The input Xml File could be even
validated against a set of Schema Files. The Schema File is the structural representation of how
a given Xml Data File should resemble.
Page 8 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Example:
Data.xml
<?xml version='1.0'?>
<bookstore>
<book genre="A" publicationdate="1981" ISBN="1-11111-11-0">
<title>title 1</title>
<author>
<first-name>A</first-name>
<last-name>B</last-name>
</author>
<price>8</price>
</book>
<book genre="B" publicationdate="1999" ISBN="0-222-22222-2">
<title>title 2</title>
<author>
<first-name>C</first-name>
<last-name>D</last-name>
</author>
<price>11.99</price>
</book>
</bookstore>
Data.xsl
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:element name="Authors">
<xsl:apply-templates select="//book"/>
</xsl:element>
</xsl:template>
<xsl:template match="book">
<xsl:element name="Author">
<xsl:value-of select="author/first-name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="author/last-name"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/xml";
string xsltFile = Path.Combine(Request.PhysicalApplicationPath, "Data.xslt"); string xmlFile =
Page 9 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Path.Combine(Request.PhysicalApplicationPath, "Data.xml");
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(xsltFile);
Windows-based authentication:
It causes the browser to display a login dialog box when the user attempts to access restricted
page.
It is supported by most browsers.
It is configured through the IIS management console.
It uses windows user accounts and directory rights to grant access to restricted pages.
Page 10 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Forms-based authentication:
Developer codes a login form that gets the user name and password.
The username and password entered by user are encrypted if the login page
uses a secure connection.
It doesn’t reply on windows user account.
The advantage is that the user only has one maintain one username and password.
Page 11 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
ASP.NET impersonation is used to control the execution of the code in authenticated and
authorized client. It is not a default process in the ASP.NET application. It is used for executing
the local thread in an application. If the code changes the thread, the new thread executes the
process identity by default.
The impersonation can be enabled in two ways as mentioned below:
Impersonation enabled: ASP.NET impersonates the token passed to it by IIS, can be an
authenticated user or an internet user account. The syntax for enabling is as shown below:
<identity impersonate=”true” />
Impersonation enabled for a specific identity: ASP.NET impersonates the token generated using
the identity specified in the Web.config file.
<identity impersonate=”true”
userName=”domain\user”
password=”password” />
Impersonation disabled: It is the default setting for the ASP.NET application. The process identity
of the application worker process is the ASP.NET account.
<identity impersonate=”false” />
Q10. Steps to use Windows authentication with sample code (Apr 2019)
When we configure our ASP.NET application as windows authentication it will use local windows
user and groups to do authentication and authorization for our ASP.NET pages.
In ‘web.config’ file set the authentication mode to ‘Windows’ as shown in the below code snippets.
<authentication mode="Windows"/>
We also need to ensure that all users are denied except authorized users. The below code
snippet inside the authorization tag that all users are denied. ‘?’ indicates any
<authorization>
<deny users="?"/>
</authorization>
We also need to specify the authorization part. We need to insert the below snippet in the
‘web.config’ file .stating that only ‘Administrator’ users will have access to
<location path="Admin.aspx">
<system.web>
<authorization>
<allow roles="questpon-srize2\Administrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
The next step is to compile the project and upload the same on an IIS virtual directory. On the
IIS virtual directory we need to ensure to remove anonymous access and check the integrated
windows authentication.
Now if we run the web application we will be popped with a userid and password box.
Page 12 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Page 13 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Advantages
Reduces the traffic travels between the client and the server.
No cross browser pains.
Better interactivity and responsiveness.
With AJAX, several multipurpose applications and features can be handled using a
single web page(SPA).
API's are good because those work with HTTP method and JavaScript.
Disadvantages
Search engines like Google would not be able to index an AJAX application.
It is totally built-in JavaScript code. If any user disables JS in the browser, it won't work.
The server information cannot be accessed within AJAX.
Security is less in AJAX applications as all the files are downloaded at client side
The data of all requests is URL-encoded, which increases the size of the request.
Page 14 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Q13. What are the benefits using Ajax? Explain UpdatePanel and ScriptManager.
(Nov 2022)
The major benefit of Ajax is partial page rendering. The partial update of a page does not
necessitate full reload of the page and hence leads to flicker-free page rendering.
UpdatePanel
We can refresh the selected part of the web page by using UpdatePanel control, Ajax
UpdatePanel control contains a two child tags that is ContentTemplate and Triggers. In a
ContentTemplate tag we used to place the user controls and the Trigger tag allows us to
define certain triggers which will make the panel update its content.
<asp:UpdatePanel ID="updatepnl" runat="server">
<ContentTemplate>
All the contents that must be updated asynchronously (only ContentTemplate parts are
updated and rest of the web page part is untouched) are placed here. It allows us to send
request or post data to server without submit the whole page so that is called asynchronous.
UpdatePanel is a container control. A page can have multiple update panels.
The UpdatePanel control enables you to create a flicker free page by providing partial-page
update support to it.
It identifies a set of server controls to be updated using an asynchronous post back.
If a control within the UpdatePanel causes a post back to the server, only the content within
that UpdatePanel is refreshed.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
Page 15 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
ScriptManager
The ScripManager Control manages the partial page updates for UpdatPanel controls that
are on the ASP.NET web page or inside a user control on the web page.
This control manages the client script for AJAX-enabled ASP.NET web page and
ScripManager control support the feature as partial-page rendering and web-service calls.
The ScriptManager control manages client script for AJAX-enabled ASP.NET Web pages.
Although this control is not visible at runtime, it is one of the most important controls for an
Ajax enabled web page.
There can be only one ScriptManager in an Ajax enabled web page.
Page 16 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Q14. Explain the use of UpdateProgress control in AJAX. (Nov 2019)(Nov 2022)
The UpdateProgress provides status information about partial page updates in UpdatePanel
controls. Despite the visual problems that post backs usually cause, they have one big advantage:
the user can see something is happening.
The UpdatePanel makes this a little more difficult. Users have no visual cue that something
is happening until it has happened. To tell users to hold on for a few seconds while their
request is being processed, we can use the UpdateProgress control.
We usually put text such as “Please wait” or an animated image in this template to let the user know
something is happening, although any other markup is acceptable as well. We can connect the
UpdateProgress control to an UpdatePanel using the AssociatedUpdatePanelID property.
Its contents, defined in the <ProgressTemplate> element, are then displayed whenever the
associated UpdatePanel is busy refreshing.
Example:
In the example below, we use the same .gif to display progress while the UpdatePanel is
updating its content. For understanding purposes, we have emulated a time-consuming
operation by setting a delay of 3 seconds by using Thread.Sleep(3000) on the button click.
protected void btnInvoke_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
lblText.Text = "Processing completed";
}
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="updProgress"
AssociatedUpdatePanelID="UpdatePanel1"
runat="server">
</ProgressTemplate>
</asp:UpdateProgress>
Page 17 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Q15. Explain the use of Timer control in AJAX. (Nov 2019) (Nov 2022)
Or
Explain about implementation of timed refresh of update panel using timer
Timer controls allow us to do postbacks at certain intervals. If used together with UpdatePanel,
which is the most common approach, it allows for timed partial updates of our page, but it can be
used for posting back the entire page as well.
The Timer control uses the interval attribute to define the number of milliseconds to occur
before firing the Tick event.
Page 18 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
The Ajax Control Toolkit is an open source library for web development. The ASP.net Ajax
Control toolkit contains highly rich web development controls for creating responsive and interactive
AJAX enabled web applications.
ASP.Net Ajax Control Toolkit contains 40 + ready controls which is easy to use for fast productivity.
Controls are available in the Visual Studio Toolbox for easy drag and drop integration with our web
application. Some of the controls are like AutoComplete, Color Picker, Calendar, Watermark, Modal
Popup Extender, Slideshow Extender and more of the useful controls.
The ASP.Net AJAX Control toolkit is now maintained by DevExpress Team. The Current
Version of ASP.Net AJAX Toolkit is v16.1.0.0. There are lot of new enhancement in the current
version from new controls to bug fixes in all controls.
The ASP.NET AJAX Control Toolkit has a lot going for it:
It’s completely free.
It includes full source code, which is helpful if we’re ambitious enough to want to create
our own custom controls that use ASP.NET AJAX features.
It uses extenders that enhance the standard ASP.NET web controls. That way, we
don’t have to replace all the controls on our web pages.
Page 19 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Accordion control provides us multiple collapsible panes or panels where only one can be
expanded at a time. Each AccordionPane control has a template for its Header and its content.
Accordion Web Control contains multiple panes and shows one at a time. The panes contain
content of images and text having wide range of supported properties from formatting of the
panes and text, like header and content templates, also it formats the selected header template.
Accordion contains multiple collapsible panes while one can be shown at a time and the extended
features of accordion also has support data source which points to the DataSourceID and binds
through .DataBind() method.
Example we have lot of paragraphs in a single page and we don’t have much space and want to
summarize in small space then we need to embed to the div or some container which can hold
all the information in accordion collapsible pans.
1. Go to File, New, then Website and Create an Empty Website. Add a webform (Default.aspx) in it.
2. Add ScriptManager from AJAX Extensions (from v15.1 of AJAX Control Toolkit,
ToolScriptManager is removed. Use Standard Script Manager).
Page 20 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
AccordionPane contains two parts i.e. Header and Content. When AccordionPane is collapsed,
only Header part is visible to us.
Page 21 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
AutoComplete is an ASP.NET AJAX extender that can be attached to any TextBox control and
will associate that control with a Popup panel to display a result returned from web services or
retrieved from a database on the basis of text in a TextBox.
The Dropdown with name retrieved from the database or web service is positioned on
the bottom-left of the TextBox.
Properties of AutoCompleteExtender:
• TargetControlID: The TextBox control Id where the user types text to be automatically completed.
• EnableCaching: Whether client-side caching is enabled.
• CompletionSetCount: Number of suggestions to be retrieved from the web service.
• MinimumPrefixLength: Minimum number of characters that must be entered before
getting suggestions from a web service.
• CompletionInerval: Time in milliseconds when the timer will kick in to get a suggestion
using the web service.
• ServiceMethod: The web service method to be called.
• FirstRowSelected: Whether the first row is selected from the suggestion.
Example:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<asp:AutoCompleteExtender ServiceMethod="GetSearch" MinimumPrefixLength="1"
CompletionInterval="10" EnableCaching="false" CompletionSetCount="10"
TargetControlID="TextBox1" ID="AutoCompleteExtender1" runat="server"
FirstRowSelected="false">
</asp:AutoCompleteExtender>
<asp:Label ID="Label1" runat="server" Text="Search Name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
Source Code:
[System.Web.Script.Services.ScriptMethod()] [System.Web.Services.WebMethod]
public static List<string> GetSearch(string prefixText)
{
SqlConnection con = new SqlConnection("connectionString"); //Create a Sql connection
SqlDataAdapter da;
DataTable dt;
DataTable Result = new DataTable();
string str = "select nvName from Friend where nvName like '" + prefixText + "%'";
da = new SqlDataAdapter(str, con);
dt = new DataTable();
da.Fill(dt);
List<string> Output = new List<string>();
Page 22 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Q20. Explain the reading process from an XML document with example (Apr 2019)
The XDocument class contains the information necessary for a valid XML document. This
includes an XML declaration, processing instructions, and comments. The XDocument makes it
easy to read and navigate XML content. We can use the static XDocument.Load() method to read
XML documents from a file, URI, or stream.
Demo for XDocument:
Authentication : It is the process of ensuring the user's identity and authenticity. ASP.NET allows
three types of authentications:
• Windows Authentication
• Forms Authentication
• Windows LiveID Authentication
Windows-based authentication:
It causes the browser to display a login dialog box when the user attempts to access restricted
page.
It is supported by most browsers.
It is configured through the IIS management console.
It uses windows user accounts and directory rights to grant access to restricted pages
I. Forms-based authentication:
Developer codes a login form that gets the user name and password.
The username and password entered by user are encrypted if the login page uses a secure
connection.
It doesn’t reply on windows user account.
II. Windows Live ID authentication:
It is centralized authentication service offered by Microsoft.
The advantage is that the user only has one maintain one username and password.
Authorization:
Authorization refers to the process that determines what a user is able to do. For example, an
administrative user is allowed to create a document library, add documents, edit documents, and
delete them. A non-administrative user working with the library is only authorized to read the
documents.
Authorization is orthogonal and independent from authentication. However, authorization requires an
authentication mechanism. Authentication is the process of ascertaining who a user is. Authentication
may create one or more identities for the current user.
Page 24 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Authentication & Authorization are two interconnected security concepts. First is process of identifying a
user and authorization is the process of checking whether authenticated user has access to the
resource which they requested
Two form of Authorization:
File: it is performed by the File Authorization Module . It uses the access control list (ACL) of the .aspx
file to resolve whether a user should have access to the file. ACL permissions are confirmed for the
users windows identity.
2) URL: in the web.config file you can specify the authorization rules for various directories of files
using the element.
Syntax is :
<system.web>
<authorization>
<system.web>
<authorization>
<allow user =”abc”/>
<deny user=”*”/>
</authorization>
<system.web>
<allow user =”abc”/>
<deny user=”*”/>
</authorization>
<system.web>
Page 25 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
3. UpdatePanel divert the clientside click and ASP.NET AJAX tells server to updates the region inside
UpdatePanel instead of full page postback.
4. On Server,Normal page Life Cycle executes.Finally the page is rendered to HTML and returned to
the browser.
5. ASP.NET AJAX receives HTML content for UpdatePanel.If changes has occurred to content that’s
not inside an UpdatePanel then it’s ignored.The ClientSide script code then updates the region
inside UpdatePanel with the new content.
Page 26 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
6. Here at the beginning as per Page Life Cycle events, Page _Load event will be executed and it will
look as follows in browser.
7. Now when we clicks on Button inside UpdatePanel ,ASP.NET AJAX requests to Server for updates
of region inside the UpdatePanel
8. On Server normal Page Life Cycle executes. First Page_Load event occurs followed by the button
click event. Final page is rendered to HTML and sent back to the browser.
9. On Browser Javascript routine update the region inside UpdatePanel and discards the rest of the
portion though it has been changed hence only the Label inside the Panel shows Latest Timing and
Label outside the Panel keep on showing past time only
Page 27 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
ScriptManager
The ScripManager Control manages the partial page updates for UpdatPanel controls that
are on the ASP.NET web page or inside a user control on the web page.
This control manages the client script for AJAX-enabled ASP.NET web page and
ScripManager control support the feature as partial-page rendering and web-service calls.
The ScriptManager control manages client script for AJAX-enabled ASP.NET Web pages.
Although this control is not visible at runtime, it is one of the most important controls for
an Ajax enabled web page.
There can be only one ScriptManager in an Ajax enabled web page.
Page 28 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Example:
Here is a small example of using the Timer control. It simply updates a timestamp every 5 seconds.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer runat="server" id="UpdateTimer" interval="5000" ontick="UpdateTimer_Tick" />
<asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" id="DateStampLabel" />
</ContentTemplate>
</asp:UpdatePanel>
We only have a single CodeBehind function, which we should add to our CodeBehind file:
protected void UpdateTimer_Tick(object sender, EventArgs e)
{
DateStampLabel.Text = DateTime.Now.ToString();
}
Page 29 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
Q25. Write a code to save employee data as empId, empName , empDept and
empDesignation data in a XML File (Nov 2022)
Certainly! You can use C# to save employee data as XML. Here's a simple example of how you
can do it:
csharp
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
class Program
{
static void Main(string[] args)
{
// Create a list of employees
List<Employee> employees = new List<Employee>
{
new Employee { EmpId = 1, EmpName = "John Doe", EmpDept = "HR", EmpDesignation
= "Manager" },
new Employee { EmpId = 2, EmpName = "Jane Smith", EmpDept = "Finance",
EmpDesignation = "Analyst" },
new Employee { EmpId = 3, EmpName = "Alice Johnson", EmpDept = "IT",
EmpDesignation = "Developer" }
};
// Create an XML serializer
XmlSerializer serializer = new XmlSerializer(typeof(List<Employee>));
Make sure to customize the employee data and file path as needed for your specific use case.
Page 30 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
MORE ACADEMY BSC IT : SEM – V AWP : U5
z Page 31 of 31
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622