is there any way to set time in asp.net like any gui control like we have in vb 6.0??

How do you intend to set/display this time for people accessing your site from different countries?

its like admin who set certain duration on website say from 9:00 am to 10:pm ect etc

Its better to retrieve the time from a server rather than use the local machine time (which can be easily amended) and compare the current server time with the duration time as held on the database.

Maintaining the duration time in a database will allow you greater flexibility as you can dynamically set this time without the need to release a web.config file or new code.

no not getting it my problem is that if have time like
if textbox1 contain "12/24/2010 07:11 PM"
and textbox2 contain "12/25/2010 08:11 AM"

and i want to calcaute just difference in hr b/w two time ,not datetime then i have
t1 = Convert.ToDateTime(Me.TextBox1.Text).ToLongTimeString()
t2 = Convert.ToDateTime(Me.TextBox2.Text).ToLongTimeString()

Dim tsdiff As TimeSpan = t2.Subtract(t1)

it should give 13 hours but right now its giving me -11 hours , can any oen help me

how to add minutes in following code

Dim st1 As String = "12/24/2010 07:00 AM"
        Dim st2 As String = "12/25/2010 11:00 AM"

        Dim startDate As DateTime = Convert.ToDateTime(st1)
        Dim stopDate As DateTime = Convert.ToDateTime(st2)

        Dim interval As Integer = 1
        Dim dateTime As DateTime = startDate
        While dateTime < stopDate
            Response.Write(dateTime & "<br>")
            'dateTime += TimeSpan.FromDays(interval)
            dateTime = dateTime + dateTime.AddMinutes(30)

        End While

i m getting an exception at this line

dateTime = dateTime + dateTime.AddMinutes(30)

i have following code

Imports System.Data
Imports System.Data.SqlClient

Partial Public Class CreateNewConference
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '  If IsNothing(Session("Login")) Then

        '  Response.Redirect("AdminLogin.aspx")

        '   End If
        'Me.TextBox1.Attributes.Add("readonly", "readonly")
        'Me.TextBox2.Attributes.Add("readonly", "readonly")

        'Me.txt_startDays.Attributes.Add("readonly", "readonly")
        'Me.txt_enddays.Attributes.Add("readonly", "readonly")
        'Dim i As Int32
        For i = 1 To 12
            Me.Start_hours.Items.Add(i.ToString())
            Me.end_hours.Items.Add(i.ToString())

        Next

        Me.ddl_am.Items.Add("am")
        Me.ddl_am.Items.Add("pm")

        Me.ddl_pm.Items.Add("am")
        Me.ddl_pm.Items.Add("pm")

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim s1 As DateTime

        s1 = Convert.ToDateTime(Me.TextBox1.Text)
        Dim timeDiff = New TimeSpan(Convert.ToDateTime(Me.TextBox2.Text).Ticks - Convert.ToDateTime(Me.TextBox1.Text).Ticks)
        Response.Write(timeDiff.Hours)

        If timeDiff.Hours > 10 And timeDiff.Hours < 4 Then
            Response.Write("Conference Duration can not be less than 4 and greater than 10")

        End If
        'Dim ex As New ExecuteTSQL
        'Dim ds As New DataSet
        'ds = ex.SelectQueryDS("Select * from Conference where Conferencename ='" & Me.txt_ConferenceName.Text & "'")

        'If ds.Tables(0).Rows.Count > 0 Then
        '    Response.Write("Already Exist")
        'Else

        '   Dim str_pickdrop As String = "insert into pickanddrop (Userid, Arrival_flight_number, Arrival_AirLine, Arrival_date,departure_flight_number,departure_AirLine,departure_date) " & _
        '"VALUES (" & userid & _
        '", '" & Me.txt_flightno.Text & _
        '"', '" & Me.txt_Airline.Text & _
        '"', '" & txt_arrival_date.Text & _
        '"', '" & Me.txt_dept_flight_no.Text & _
        '"', '" & Me.txt_departure_airline.Text & _
        '"', '" & Me.txt_departure_date.Text & "')"

        'obj.IUD("insert into product(name,description,active,productdate,wholesalerprice,retailprice) values('"+this.txtproduct.Text+"','"+this.txtdp.Text+"',1,'"+System.DateTime.Now.ToString()+"',"+this.txtwholesale.Text+","+this.txtprice.Text+")");

        'ex.IUD("insert into conference ([Conferencename] ,Business_Hours,ConferenceDays,NumberOfsession,StartDate,EndDate) values ('" & Me.txt_ConferenceName.Text & "','" & Me.txt_businessHours.Text & "','" & Me.txt_conference_days.Text & "','" & Me.txt_SesssionNumber.Text & "','" & Me.txt_startDays.Text & "','" & Me.txt_enddays.Text & "')")
        '"','" & Me.txt_businessHours.Text & "' ,'" & Me.txt_conference_days & "','" & Me.txt_startDays.Text & "' ,'" & Me.txt_enddays.Text & "')")
        ''Dim ICon As String =( "insert into conference ([Conferencename] ,Business_Hours,ConferenceDays,NumberOfsession,StartDate,EndDate)    "VALUES ('" & Me.txt_ConferenceName.Text            ", '" & Me.txt_businessHours.Text & _
        '"', '" & Me.txt_conference_days & _
        '"', '" & Me.txt_SesssionNumber.Text & _
        '"', '" & Me.txt_startDays.Text & _
        '"', '" & Me.txt_enddays.Text & "')"

        '" VALUES ('" & Me.txt_ConferenceName.Text & "' _"
        ', '" & Me.txt_businessHours.Text & _
        '"','" & Me.txt_conference_days & "' ,'" & Me.txt_SesssionNumber.Text & "', '" & Me.txt_startDays.Text & "' ,'" & Me.txt_enddays.Text & "')"
        '' Response.Redirect()

        'End If





    End Sub

    'Protected Sub btn_calculate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_calculate.Click
    '    '   Me.txt_C_days.Text = DateDiff(DateInterval.Day, Convert.ToDateTime(Me.txt_startDays.Text), Convert.ToDateTime(Me.txt_enddays.Text))

    'End Sub
End Class

but i m getting an error see an attahced image at line $('#TextBox1').datetimepicker();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.