Here my first post is regarding Ajax.
So here I am going to give you a simple example how to update the controls outside the update panel without postback
Code behind file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class scriptMgr : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Label1 upadte" + DateTime.Now.ToString();
Label2.Text = "Label2 updated" + DateTime.Now.ToString();
if (ScriptManager1.IsInAsyncPostBack)
{
ScriptManager1.RegisterDataItem(Label3, DateTime.Now.ToString());
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "Label1 " + DateTime.Now.ToString();
Label2.Text = "Label2 " + DateTime.Now.ToString();
if (ScriptManager1.IsInAsyncPostBack)
{
ScriptManager1.RegisterDataItem(Label3, "Label3 "+DateTime.Now.ToString());
}
}
}
Aspx page
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script type="text/javascript" language="javascript">
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(PageLoadingHandler);
function PageLoadingHandler(sender, args) {
var dataItems = args.get_dataItems();
if ($get('Label3') != null)
$get('Label3').innerHTML = dataItems['Label3'];
}
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /><br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Label ID="Label3" runat="server" Text="krwelkr"></asp:Label>
<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" />
</div>
You can find Ajax Books
Professional ASP.NET 3.5 AJAX (Wrox Programmer to Programmer)
Microsoft ASP.NET and AJAX: Architecting Web Applications (PRO-Developer)
ASP.NET, C#, SQL Server Blog
The ZEN of ASP.NET,C#,SQL Server programming
Categories
- Anonymous Methods (1)
- C# 3.0 Feature (1)
- C# 3.0 Features (1)
- Creating HTML Table Dynamically (1)
- DataView Advanced Filtering with Relationships in C# And ASP.NET (1)
- DataView and DataTable Sorting (1)
- Deserialisation between any objects (1)
- Dynamically Adding Multiple Data Tables Relationships (1)
- Filtering Data in a DataTable (1)
- How to Write Stored Procedures (1)
- Implicitly Typed Local Variables (1)
- Internet Explorer (1)
- Lambda Expressions (1)
- Lamda Expression (1)
- LinQ (1)
- LinQ to XML (1)
- Minimize All (1)
- Object Initializing (1)
- Reading the XML file (1)
- Runnig batch script from C# (1)
- Running Process from C# (1)
- Script Manager (1)
- Serialisation (1)
- SHDocVw (1)
- Sorting with a DataView (1)
- Stored Procedures (1)
- Tips and Tricks VS 2010 (1)
- Update Controls Outside Update Panel With Out Postback (1)
- Update Panel (1)
- Using Two Arguments in a Lambda Expression (1)
- Windows 7 (1)
- XML node traversal (1)
About Me
Followers
Powered by Blogger.
Blog Archive
Total Hits
Search
©2008. All rights Reserved
: