Posts Tagged ‘update panel’

Adding UserControl Dynamically and Set Properties in

November 8, 2010 1 comment

Adding UserControl Dynamically and Set Properties in

ucMyUserControl ucUser = (ucMyUserControl )LoadControl(“~/folder/MyUserControl.ascx”);
ucUser.MyProperty = “I got my property”; 

For More Details Visit :


Refresh Content in UpdatePanel using Ajax Timer Control

January 19, 2010 1 comment

Lets say we have a requirement where we have a label control and we have assigned date time to its text, and in every 5 seconds we want to update the time, over there we need to place the label control inside the update panel and use a timer control to update its content.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<head runat="server">
    <title>Update Panel and Timer</title>
    <form id="form1" runat="server">
        <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">
                <asp:AsyncPostBackTrigger controlid="UpdateTimer"
                  eventname="Tick" />
                <asp:Label runat="server" id="lbldatetime" />

In the codebehind:

protected void UpdateTimer_Tick(object sender, EventArgs e)
lbldatetime.Text = DateTime.Now.ToString();