We help IT Professionals succeed at work.
Get Started

Timer countdown sql, asp.net c#

bside2011 asked
Last Modified: 2012-05-11
i have the next javascript code at my try.aspx file:
<input type="hidden" id="auctionEndDate" value="<%=TargetDate%>"> 
<script language="JavaScript"> 
    TargetDate = "document.forms[0].TargetDate.value"; 
    /*this is a property in code behind*/BackColor = "palegreen"; 
    ForeColor = "navy"; 
    CountActive = true; 
    CountStepper = -1; 
    LeadingZero = true; 
    DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; 
    FinishMessage = "the auction end" 
    <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> 

Open in new window

code behind:
public string TargetDate () 
    String tDate = "";  
    DataTable dataTable = new DataTable();  
    using (SqlConnection connection = new SqlConnection("Server=localhost;Database=Timer;Trusted_Connection=True"))  
    using (SqlCommand command = connection.CreateCommand())    
        command.CommandText = "select * from endTime";      
        SqlDataReader reader = command.ExecuteReader();     
        tDate = dataTable.Rows[0][0].ToString(); // Expecting the first row and first column 
    return tDate; 

Open in new window

but i got that error:
CS1502: The best overloaded method match for 'System.IO.TextWriter.Write(char)' has some invalid arguments

for the line:
<input type="hidden" id="auctionEndDate" value="<%=TargetDate%>">

what i'm trying to do is to build timer countdown for item, and the endtime coming from sql database. maybe all the way is wrong, i'll be glad to get others way to do that, or fix the error's on the code that i post here.
Watch Question
This problem has been solved!
Unlock 1 Answer and 14 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE