PLZ hELP ME IN.....DATE COMPARISON!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As New Date
If dt.Day() <= 16 Then
ElseIf dt.Day() >= 17 Then
Label1.Text = "error"
Im the beginner for the asp.net .
I would like to allow user to view the results before 16/mm/yyyy and disallow when the date is reached after 17/mm/yyyy.....
but when i write this code in the page load.....all the msgbox i get is ("allow") althougt the date is reached after 17/mm/yyyy.....
pls help me. to solve this problem.....!
Well, first of all, you cannot display a MsgBox in ASP.NET. ASP.NET code runs on the Web server, so users of your site would not be able to see a MsgBox. Generally, you would use a Literal or some other control on the page to display a message to the user.
You are creating a new variable of type Date, but I don't see where you assign a value to it. Which date do you want to compare to 16 or 17? Today's date? Or a date that's passed in from the Web page?
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Your Date variable has not been initialized. Instead try:
Microsoft MVP (Visual Basic)
thanks phil weber and pclement!
i already solved my problem.
But i still got 1 question as below:
if msgbox can't use.....
so what is the best way to prompt the message instead of using msgbox?
You can use a message box..
Try out this one..
if you are using a button to check your code try applying this..
Since I am using C# the code goes like this
in page load event
Button1.OnClientClick = String.Format("return alert('your custom message')");
now when you'll click on the button.. you'll see a message box..
By hemanthjava in forum Java
Last Post: 07-05-2006, 11:08 PM
Last Post: 05-23-2005, 12:31 PM
By jbricher in forum ASP.NET
Last Post: 04-10-2005, 01:37 PM
By rtwitty in forum VB Classic
Last Post: 02-24-2005, 02:12 PM
By sxy in forum VB Classic
Last Post: 06-12-2002, 12:00 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center