how can i get time on checkbox selection

Posted by Priti2010 under ASP.NET AJAX on 9/22/2011 | Points: 10 | Views : 1078 | Status : [Member] | Replies : 4
i want to get checkbox selection time which is to be saved in table and also restricted the checkbox not to excedd the time limit

Thanks & Regards
Priti



Responses

Posted by: Ndebata on: 9/22/2011 [Member] Starter | Points: 25

Up
0
Down
Use DateTime.Now in checkchanged event in server side.
in aspx file
<asp:CheckBox ID="CheckBox1" AutoPostBack="true" OnCheckedChanged="CHK_CHNGED" runat="server" />


in .cs file
protected void CHK_CHNGED(object sender,EventArgs e)

{
if (CheckBox1.Checked)
Response.Write(DateTime.Now);
}




Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Priti2010 on: 9/22/2011 [Member] Starter | Points: 25

Up
0
Down
thanx for the help
i have try this method but i want only the time and also the checked time should be added in the datagrid. i have try this by declaring a string
for eg: Dim mytime As String
mytime = TimeOfDay
and then
mytime = Convert.ToString(chkServer1.Checked)
but instead of time to be saved in datagrid only the checked value true or false is saved as string.


Thanks & Regards
Priti

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 9/22/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,
Add the code mytime=TimeOfDay in the checked change event and bind this value in the datagrid. In your above code you saved the checked value into the variable mytime.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 9/22/2011 [Member] Starter | Points: 25

Up
0
Down
Protected Sub CHK_CHNGED(sender As Object, e As EventArgs)


If CheckBox1.Checked Then
'Then use my time to save
Dim mytime As String = DateTime.Now.ToShortTimeString()
End If

End Sub

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response