Professional Documents
Culture Documents
UpdatePanel Control in
UpdatePanel Control in
Net
In Focus
C#IsCorner Named a leader in the
Look Who Speaking at #CSharpCon19
Apigee API 2018 Gartner Magic
ASK A QUESTION
Management Quadrant. DownloadCONTRIBUTE
the
report today.
3 0 110.2k
Introduction
This article describes how to add partial page update support to a web page by using two
Microsoft Ajax server controls the ScriptManager Control and the UpdatePanel Control. Using
UpdatePanel control we can refresh only required part of the page instead of whole page.
ScriptManager Control
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.
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 1/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Speaking at #CSharpCon19
UpdatePanel Control
You 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
ContenTemplate tag we used to place the user controls and the Trigger tag allows you to
de ne certain triggers which will make the panel update its content.
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 submitting the whole page so that is called
asynchronous.
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 2/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Speaking at #CSharpCon19
Now I am going to show you how to check the availability of user name in database let's
follow the following steps:
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 3/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Speaking at #CSharpCon19
Step 1
Step 2
Now go the solution explorer on to the right side of the application and do the following steps
gure given below.
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 4/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Speaking at #CSharpCon19
Step 3
Add new Web form in the empty web application gure given below.
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 5/11
20/04/2019 UpdatePanel Control in ASP.Net
InStep
Focus4
C#IsCorner
Look Who Speaking at #CSharpCon19
01. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckAvailability
ASK A QUESTION CONTRIBUTE
02. <%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"
03. <!DOCTYPE html>
04. <html xmlns="http://www.w3.org/1999/xhtml">
05. <head id="Head1" runat="server">
06. <title></title>
07. </head>
08. <body>
09. <form id="form1" runat="server">
10. <asp:ScriptManager ID="scriptmanager1" runat="server">
11. </asp:ScriptManager>
12. <div>
13. <asp:UpdatePanel ID="updatepnl" runat="server">
14. <ContentTemplate>
15. <table>
16. <tr>
17. <td>Enter UserName </td>
18. <td>:</td>
19. <td>
<asp:TextBox ID="txtun" runat="server" AutoPostBack="true" OnTextChanged=
</td>
20. <td>
21. <div id="checkun" runat="server" Visible="false">
22. <asp:Image ID="shwimg" runat="server" Width="17px" Height="17px"/>
23. <asp:Label ID="lblmsg" runat="server"></asp:Label>
24. </div>
25. </td>
26. </tr>
27. <tr>
28. <td>Enter Password </td>
29. <td>:</td>
30. <td><asp:TextBox ID="txpwd" runat="server" TextMode="Password">
</asp:TextBox></td>
31. </tr>
32. <tr>
33. <td>Enter Confirm Password </td>
34. <td>:</td>
35. <td><asp:TextBox ID="txtconpwd" runat="server" TextMode="Password">
</asp:TextBox></td>
36. </tr>
37. <tr>
38. <td colspan="3">
<asp:Button ID="txtbtn" Text="SUBMIT" runat="server" align="center" />
</td>
39. </tr>
40. </table>
41. </ContentTemplate>
42. </asp:UpdatePanel>
43. </div>
44. </form>
45. </body>
46. </html>
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 6/11
20/04/2019 UpdatePanel Control in ASP.Net
InStep
Focus5
C#IsCorner
Look Who Speaking at #CSharpCon19
01. using System;
ASK A QUESTION CONTRIBUTE
02. using System.Collections.Generic;
03. using System.Linq;
04. using System.Web;
05. using System.Data;
06. using System.Data.SqlClient;
07. using System.Web.UI;
08. using System.Web.UI.WebControls;
09. public partial class CheckAvailability : System.Web.UI.Page
10. {
11. protected void Page_Load(object sender, EventArgs e)
12. {
13. }
14. protected void CheckUserNameAvailability(object sender, EventArgs e)
15. {
16. if (!string.IsNullOrEmpty(txtun.Text))
17. {
18. SqlConnection con = new SqlConnection("Data Source=MCNDESKTOP
19. con.Open();
20. SqlCommand cmd = new SqlCommand("select * from UserDetails wh
21. cmd.Parameters.AddWithValue("@un", txtun.Text);
22. SqlDataReader dr = cmd.ExecuteReader();
23. if (dr.HasRows)
24. {
25. checkun.Visible = true;
26. shwimg.ImageUrl = "Cancel.png";
27. lblmsg.Text = "UserName Already Exist..!!";
28. }
29. else
30. {
31. checkun.Visible = true;
32. shwimg.ImageUrl = "Accepted.png";
33. lblmsg.Text = "Congratulation created Successfully..!!";
34. }
35. }
36. else
37. {
38. checkun.Visible = false;
39. }
40. }
41. }
Step 6
Debug the application by press (F5) to execute Web form. After debugging the application
then the output would be as shown below.
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 7/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Speaking at #CSharpCon19
Step 7
Enter the User Name to check it is available in database or not, gure given below.
Step 8
Enter the User Name to check it is available in database or not, gure given below.
Summary
In this article you saw by using two Microsoft Ajax server controls the ScriptManager Control
and the UpdatePanel Control we can refresh only required part of the page instead of whole
page.
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 8/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Speaking at #CSharpCon19
Pankaj Lohani
https://www.c-sharpcorner.com/members/pankaj-lohani2
251 1.2m
3 0
Type your comment here and press Enter Key (Minimum 10 characters)
OUR TRAINING
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 9/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Speaking at #CSharpCon19
Holiday in Dubai
TRENDING UP
Implement CRUD Operations With Sorting, Searching And Paging Using EF Core In
06 ASP.NET Core
07 For Vs Foreach In C#
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 10/11
20/04/2019 UpdatePanel Control in ASP.Net
In Focus
C#IsCorner
Look Who Hotels in Mumbai
Speaking at #CSharpCon19
from 450
ASK A QUESTION CONTRIBUTE
Book Now
Hotels in London
from 935
Book Now
Hotels in Bangkok
from 437
Book Now
About Us Contact Us Privacy Policy Terms Media Kit Sitemap Report a Bug FAQ Partners
C# Tutorials
©2019 C# Corner. All contents are copyright of their authors.
https://www.c-sharpcorner.com/UploadFile/f50501/use-updatepanel-control-in-Asp-Net/ 11/11