Wednesday, March 21, 2012

Use Ajax on the label

Hi all

on the label i am using the code

protected void Page_Load(object sender, EventArgs e)
{
this.lTime.Text = Convert.ToString(DateTime.Now.TimeOfDay);
}

this is showing fised time

but i want to change the time acording to the second how this is possible?

Thanks

Hi there,

Have a look at this article

http://ajax.asp.net/docs/tutorials/IntroToTimerControl.aspx

Hope it helps ;)


You can change the label content on Javascript

1. Get the label client ID (If you're not using master page and the label is not inside an inner control it should be the
same as the ID you gve to the label)

2. Get the label by document.getElementById or $get

3. Change it's textContent property (Mozilla) or innerHTML / innerText (IE) property of the object and than the label content will change


I am getting some problem here!

I read the post 2

and make a user control name header and done all the coding on that page

after I make a master page i first cell i add a script manager then i put update panel there I drag that user control in the update panel ! That i make for the timer so it showing me the following error

Error Rendering control -UpdatePanel1

An Unhandled Exception has occured.
The control with ID 'Timer1' requires s script Manager on this page.The Script Manager must appear before any controls that need it!


Hi There,

Simple Example: NOTE SCRIPT MANAGER HAS TO BE FIRST

ASPX

<asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>

<asp:UpdatePanelID="UpdatePanel3"runat="server">

<ContentTemplate>

<asp:TimerID="Timer1"runat="server"Interval="1000"OnTick="Timer1_Tick">

</asp:Timer>

<asp:LabelID="Label2"runat="server"Text="Label"></asp:Label>

</ContentTemplate>

</asp:UpdatePanel>

ASPX.VB

protectedvoid Timer1_Tick(object sender,EventArgs e)

{

Label2.Text =DateTime.Now.ToString();

}

IF above not working, Could you post your code here so that me or others can guide you through this.


Are you using the AJAX enabled website

I am not using that

is it necessary to use the AJAX enabled website for using the AJAX?


hi

just go through the following link

http://ajax.asp.net/docs/overview/UsingTimerControlTutorial.aspx#CodeExamples


shakti5385:

is it necessary to use the AJAX enabled website for using the AJAX?

It's not necessary, the key difference is in the web.config.

You may modify any existing web site's config file to make it work with AJAX.

Here is the documentation regarding it. http://ajax.asp.net/docs/ConfiguringASPNETAJAX.aspx

No comments:

Post a Comment