Answered by:
Show message in textbox as per time and blink if clause is yes

Question
-
User810354248 posted
In my asp.net+vb+SQL web i have a textbox named messagebox.text. I want to check the time of server is between 6am to 6pm if yes then show a message and not to blink
f no then show another message and blink th etext in text box
i used this
VB
If theTime >= #6:00:00 PM# AndAlso theTime <= #5:59:59 PM# Then messagebox.Text = "Booking will be available between 6Am to 6 PM only.." Else messagebox.Text = "On Line Booling Status: Active)" End If
aspx
<script src="jquery/jquery-blink.js" language="javscript" type="text/javascript"></script> <script type="text/javascript" language="javascript"> $(document).ready(function () { $('.blink').blink(); // default is 500ms blink interval. //$('.blink').blink({delay:100}); // causes a 100ms blink interval. }); </script> <asp:Label ID="messagebox" class="blink" style="color: #FF0000; font-weight: 700" runat="server"></asp:Label>
Even if the time is correct the above code is not working for me
but it blinks for both
my requirement was if the server time is between 6am to 6pm then i want to give permission to user to book/ order something
other wise show a message the booking will start at 6am-6pm only
Sunday, December 30, 2018 5:17 AM
Answers
-
User61956409 posted
Hi Baiju EP,
I want to check the time of server is between 6am to 6pm if yes then show a message and not to blink
if no then show another message and blink the text in text box
You can determine if the current time falls in 6am to 6pm and conditionally call JavaScript function to blink text from your code behind, like below.
<script> function lblblink() { $('.blink').blink(); } </script>
Dim start_ts As TimeSpan = New TimeSpan(6, 0, 0) Dim end_ts As TimeSpan = New TimeSpan(18, 0, 0) Dim Now As TimeSpan = DateTime.Now.TimeOfDay If (Now > start_ts) And (Now < end_ts) Then messagebox.Text = "On Line Booling Status: Active)" Else messagebox.Text = "Booking will be available between 6Am to 6 PM only.." ClientScript.RegisterStartupScript(Me.GetType(), "BlinkLabel", "lblblink()", True) End If
With Regards,
Fei Han
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 31, 2018 2:31 AM -
User-943250815 posted
@Baiju EP, both samples work as your request.
If you are using Fei Han sample, you have to remove "$('.blink').blink();
" call from "$(document).ready
" other than blink will be called twice- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 31, 2018 2:15 PM
All replies
-
User-943250815 posted
What about add a HiddenField, you can set value with your IF, and check the value to decide if should blink or not
If theTime >= #6:00:00 PM# AndAlso theTime <= #5:59:59 PM# Then messagebox.Text = "Booking will be available between 6Am to 6 PM only.." HiddelField1.value = "1" Else messagebox.Text = "On Line Booling Status: Active)" HiddelField1.value = "0" End If
<script type="text/javascript" language="javascript"> $(document).ready(function () { if ($('#<%=HiddenField1.ClientID%>').val() == 0) { $('.blink').blink(); // default is 500ms blink interval. } else { // do whatever you want } }); </script>
Sunday, December 30, 2018 4:22 PM -
User61956409 posted
Hi Baiju EP,
I want to check the time of server is between 6am to 6pm if yes then show a message and not to blink
if no then show another message and blink the text in text box
You can determine if the current time falls in 6am to 6pm and conditionally call JavaScript function to blink text from your code behind, like below.
<script> function lblblink() { $('.blink').blink(); } </script>
Dim start_ts As TimeSpan = New TimeSpan(6, 0, 0) Dim end_ts As TimeSpan = New TimeSpan(18, 0, 0) Dim Now As TimeSpan = DateTime.Now.TimeOfDay If (Now > start_ts) And (Now < end_ts) Then messagebox.Text = "On Line Booling Status: Active)" Else messagebox.Text = "Booking will be available between 6Am to 6 PM only.." ClientScript.RegisterStartupScript(Me.GetType(), "BlinkLabel", "lblblink()", True) End If
With Regards,
Fei Han
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 31, 2018 2:31 AM -
User810354248 posted
the script i placed in aspx page and used the above code. now the time clause is working as per my requirement but the blink is being done for both messages . I want the blink for time 6pm to 6am only.
<script> function lblblink() { $('.blink').blink(); } </script>
Monday, December 31, 2018 4:21 AM -
User-943250815 posted
@Baiju EP, both samples work as your request.
If you are using Fei Han sample, you have to remove "$('.blink').blink();
" call from "$(document).ready
" other than blink will be called twice- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 31, 2018 2:15 PM