Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
Change image position according to system time.
Old 02-03-2009, 07:20 PM Change image position according to system time.
Average Talker

Posts: 26
Name: Adam Kischinovsky
Trades: 0
Hi I have made a website where it is possible to see the days program on one page, it updates itself so it is only for that day.

But now I wan't to be able to insert a picture that changes position according to what time it is.

For example if the time is 1pm. then the small picture should move down to 1pm.
and if the time is 3pm the picture moves down to 3pm.

Maybe you can see what I meen on:
http://radio.web.surftown.dk/default.aspx

the time is written as datetime in my ms sql database

my code on my aspx page looks like this:

Code:
<%# Eval("tid", "{0:t}")%>
and my code on the codebehind page looks like this:

Code:
SqlConnection objconn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ToString());
            SqlCommand objcmd = new SqlCommand();


            objcmd.Connection = objconn;
            objcmd.CommandType = CommandType.Text;

            if (DateTime.Now.Hour > 3)
            {

                objcmd.CommandText = "SELECT * FROM PROGRAM WHERE CONVERT(VARCHAR, date, 105) = CONVERT(VARCHAR, GETDATE(), 105)";
            
           
            SqlDataReader reader = null;

            objconn.Open();
            reader = objcmd.ExecuteReader();
            program.DataSource = reader;
            program.DataBind();

            objconn.Close();
            }
    
         else
            {
                objcmd.CommandText = "SELECT * FROM PROGRAM WHERE DATE = DATEADD(day, DATEDIFF(day, 1, GETDATE()), 0)";

                SqlDataReader reader = null;

                objconn.Open();
                reader = objcmd.ExecuteReader();
                program.DataSource = reader;
                program.DataBind();

            }

        }
I think that this might be a way to do it?

my column in my ms sql Db that the system time has to be the same as is called tid.
So I have a suspicion that it could be done something like this:

Code:
objcmd.CommandText = "SELECT tid FROM PROGRAM CONVERT(VARCHAR, GETDATE(), {0:t})";

and then later make an if sentence.

if(tid == getdate() "{0:t}")
{
  insert picture with img src="x";
}

But I am not sure and don't know haw I should write it if I am right.

I hope you understand what I meen and that you can help me?

Last edited by Kischi; 02-04-2009 at 01:18 PM..
Kischi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-07-2009, 12:35 PM Re: Change image position according to system time.
Junior Talker

Posts: 3
Trades: 0
why not you darw the image using system.drawing run time and make a user control to make it easy

Regards
__________________
Aditya

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
adityagarg is offline
Reply With Quote
View Public Profile
 
Old 02-09-2009, 09:07 AM Re: Change image position according to system time.
Average Talker

Posts: 26
Name: Adam Kischinovsky
Trades: 0
Sorry but I don't know how to do that.

could you please help me walk through it with my code, for example where I insert the code and wich control I use?

thx
Kischi is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Change image position according to system time.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11066 seconds with 12 queries