Thursday, 21 May 2015

Ajax Call Using UpdatePanel Display Data On Button Click Without Refresh In Asp.Net, C#

5/21/2015 - By Pranav Singh 0

This article will show you how you can do ajax call using updatepanel display data on button click without refresh in asp.net and c#.

Some of my previous articles are as follows: Call C# Code or Function or Method From Javascript In Asp.Net, Get All Checked Checkbox Value Using jQuery in Asp.Net CheckBoxList, Get RadioButton Value Using jQuery In Asp.Net, Comment System OR Form and Display In GridView Using C# In Asp.Net, Excel File Upload Or Import and Display In GridView Using C# In Asp.Net, Read List Of File From Server and Display In GridView Using C# In Asp.Net, How to Change DateTime Format Using C# In Asp.Net, Facebook like Button Integration In Asp.net Using C#.Net.

So for this article first I have created a new asp.net application and now on page add the ScriptManager and UpdatePanel. Now on update panel add a button control and a label. In this when you click on button the label text will change without refreshing the page.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Ajax Call Using UpdatePanel Display Data On Button Click Without Refresh In Asp.Net, C#</title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="Label" Style="font-weight: 700; font-size: x-large"></asp:Label>
                <br />
                <br />
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Now use the below code to display the text on label control.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "This is server side ajax call";
        }
    }
}

Now we have done run the application to check the output.

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top