Try this count up timer.
00:00:00:000
The source code is like below:
<script language="javascript"> |
Sharing programming and database problem with you, especially in .NET programming, Javascript and SQL Server 2000.
Try this count up timer.
00:00:00:000
The source code is like below:
<script language="javascript"> |
Posted by bm_boy at 8:16:00 PM 0 comments
setTimeout
and setInterval
Methods
Here, i would like to share with you how to use the JavaScript's settimeout()
, clearTimeout()
, setInterval()
and clearinterval()
methods to set timers and create delayed actions.setTimeout()
The general syntax of window.setTimeout()
method is:
setTimeout(expression, timeout); |
expression
is the JavaScript code to run after timeout
miliseconds have elapsed.setTimeout()
return a numeric timeout ID that can be used to track the timeout. This is most commonly used with the clearTimeout()
method.setTimeout()
is called, execution of the following script will continue normally. The expression in setTimeout()
will be run when pass the timeout period.<script language="javascript"> |
clearTimeout()
window.clearTimeout()
method is used to cancel a timer before it goes off. It's syntax is:clearTimeout(timeoutId); |
timeoutId
is the timeout ID returned from the setTimeout() method call.<script language="javascript"> |
setInterval()
setInterval()
function is very same to setTimeout()
even the their syntax is similar. It's syntax is:setInterval(expression, interval); |
setTimeout()
triggers expression
only once but setInterval()
keeps triggering expression
again and again unless stop it.clearInterval()
setInterval()
, call clearInterval()
method. It's syntax is like below:clearInterval(intervalId); |
intervalId
is the interval ID returned from the setInterval() method call.setInterval()
and clearInterval
. When visitor click the button at below, the following code start to count up and display it until visitor click the button again to stop it.<script language="javascript"> |
Posted by bm_boy at 3:57:00 PM 0 comments
The following is the sample code how to query an Excel spreadsheet from an ASP.NET page using VB .NET:
Dim strConn As String Dim da As OleDbDataAdapter Dim ds As New DataSet strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\test.xls;Extended Properties=""Excel 8.0;""" da = New OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn) da.TableMappings.Add("Table", "Excel") da.Fill(ds) dataGrid1.DataSource = ds.Tables(0).DefaultView dataGrid1.DataBind() da.Dispose() |
Dim dao_dbE As dao.DBEngine Dim dao_DB As DAO.Database Dim strFirstSheetName As String dao_dbE = New dao.DBEngine dao_DB = dao_dbE.OpenDatabase("C:\test.xls", False, True, "Excel 8.0;") strFirstSheetName = dao_DB.TableDefs(0).Name da0_DB.Close() |
Dim strConn As String Dim da As OleDbDataAdapter Dim ds As New DataSet Dim dao_dbE As dao.DBEngine Dim dao_DB As DAO.Database Dim strFirstSheetName As String dao_dbE = New dao.DBEngine dao_DB = dao_dbE.OpenDatabase("C:\test.xls", False, True, "Excel 8.0;") strFirstSheetName = dao_DB.TableDefs(0).Name strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\test.xls;Extended Properties=""Excel 8.0;""" da = New OleDbDataAdapter("SELECT * FROM [" & _ strFirstSheetName & "]", strConn) da.TableMappings.Add("Table", "Excel") da.Fill(ds) dataGrid1.DataSource = ds.Tables(0).DefaultView dataGrid1.DataBind() da.Dispose() da0_DB.Close() |
Posted by bm_boy at 9:43:00 PM 0 comments
If you try to get currently logged on user name with User.Identity.Namein ASP.NET, but the return value is empty string.
The following is syntax accesses this variable in C# .NET:
string strUserName = User.Identity.Name; |
<authentication mode="Forms" /> |
<authorization> <deny users = "?" /> <!-- This denies access to the Anonymous user --> <allow users = "*" /> <!-- This allows access to all users --> </authorization> |
<authentication mode="Windows" /> |
1. Go to Internet Services Manager, right-click the .aspx file or the Web Project folder, and then click Properties. 2. If you clicked Properties for the Web Project folder, click the Directory Security tab. If you clicked Properties for the .aspx file, click the File Security tab. 3. Under Anonymous Access and authentication control, click Edit. 4. In the Authentication methods dialog boc, clear the Anonymous Access check box, and then select either theBasic, the Digist or the Integrated (NT Challenge/Response) check box. 6. Click OK to close both dialog boxes. |
Posted by bm_boy at 11:27:00 PM 0 comments
This is the function at html page:
<script language="javascript"> function test(){ //Add the function code here } </script> |
Dim strScript As string = "<script language='javascript' id='myClientScript'>test();</script>" Page.RegisterStartupScript("callTest", strScript) |
Posted by bm_boy at 11:37:00 PM 0 comments
This happen when try to call a Web service application and Anonymous access authentication is turned off.
You can solve this problem by using the Credentials property of the Web service client proxy to set the security credentials for Web service client authentication.
Assign the DefaultCredentials to the Credentials property of the Web Service Proxy class to call the Web service while Anonymous access authentication is turned off. See the following code:
//Assigning DefaultCredentials to the Credentials property //of the Web service client proxy(ws) ws.Credentials = System.Net.CredentialCache.DefaultCredentials |
Posted by bm_boy at 5:10:00 PM 0 comments
I faced this error before.
I used my local pc's window service application to call a web service function at server (different pc) but it is fail. It cannot work like when I used the same window service application to call the same web service function at local pc.
Then, I tried to browse to the web service through ie. When I click the fuction, it showed the message - "The test form is only available for requests from the local machine"
After that, I found the solution to fix it. I just added in some code inside the
web.config file then the this problem is solved. The code I added in is like below:
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
Posted by bm_boy at 12:12:00 PM 0 comments
DATEADD is a date function will return a datetime value based on the number interval add to the particular date part of the specified date. The syntax DATEADD is like:
DATEADD(date_part, number_interval, specified_date) |
MONTH, MM or M for month |
YEAR, YYYY, YY for year |
DAY, DD, D for day |
HH for hour |
SS, S for Second |
SELECT DATEADD(D, -1, GETDATE())AS [Yesterday] |
SELECT DATEADD(MM, 3, GETDATE())AS [FourMonthsFromNow] |
SELECT DATEADD(YEAR, -2, GETDATE())AS [TwoYearsAgo] |
Posted by bm_boy at 10:54:00 AM 0 comments
I wrote a Windows Service application in VB.NET before and i faced a problem. I used timer to do the schedule task in this application. I dropped a Timer Control on the designer then add the Tick event to do the schedule task. I can built, install, stop and restart the service. However the problem is it the Tick event never fires at all.
After that, i try to use code to create the timer. I changed to use System.Timers.Timer instead of System.Windows.Forms.Timer dropped on the designer from Toolbox. Then it is work already. The code is like below:-
Dim timerSchedule As System.Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
timerSchedule = New System.Timers.Timer(1000)
AddHandler timerSchedule.Elapsed, AddressOf timerSchedule_Elapsed timerSchedule.Start() End Sub
Private Sub timerSchedule_Elapsed(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)
Try timerSchedule.Stop()
'call my a function to do the scheduled task
DoScheduledTask()
Catch ex As Exception
Finally
timerSchedule.Start()
End Try End Sub
Try to know more about System.Timers Namespace, it will here you more.
Posted by bm_boy at 5:11:00 PM 0 comments