Wednesday, March 28, 2012

Change Between 2 Labels?

Okay lets say that i have 2 Labels and i Want AJAX to Change Between thoes when a given interval is reached, And what that do happen Automatic and Random Choice(Of thoes Labels Avai.)

I have the code behinde looking like this

Random RandomClass = new Random();
int n = RandomClass.Next(1, 2);
Label1.Text = "Tester";
Label1.Text = "damn";

But when i load the site.. Sure A Label is chose the last one and nothing else happen... Someone Please Direct me the correct direction :D

Are you trying to show and hide each labels on specific interval?

okay lets say i have 2 or 3 labels..

one text "Test"

and the other "Tester"

the last "Asp.net"

And i want the timer to Random choose one to show... the texts could be small quotes or some...


*BUMP*

Someone? :D


Hi.

You can use this code.

<asp:ScriptManager ID="sm1" runat="server" /> <asp:UpdatePanel ID="up1" runat="server" UpdateMode="always"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Tester" ></asp:Label> <asp:Label ID="Label2" runat="server" Text="damn" ></asp:Label> <asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick"> </asp:Timer> </ContentTemplate> </asp:UpdatePanel>

protected void Timer1_Tick(object sender, EventArgs e) { Random RandomClass =new Random();int n = RandomClass.Next(1, 3);if (n == 1) { Label1.Text ="Tester"; Label2.Text ="damn"; }else { Label1.Text ="damn"; Label2.Text ="Tester"; } }

Regards.


Thx mate ill try :D..

Is there a smart way than then

Else

cause if i have like 20 it will be pretty messy


*Bump*

Someone know a "smarter" way?

No comments:

Post a Comment