This is the function at html page:<script language="javascript">
function test()
{
//Add the function code here
}
</script>
To call this javascript function from code behind (.vb), Use Page.RegisterStartupScript
function like the code below:Dim strScript As String = "<script language='javascript' id='myClientScript'>test();</script>"
Page.RegisterStartupScript(“callTest”,strScript)
Thursday, March 20, 2008
Calling Javascript Function from Code Behind (.vb)
Posted by Wec at 5:10:00 PM 3 comments
Labels: .NET Programming, ASP .NET 1.1, VB.NET
Tuesday, March 18, 2008
SQL Query Script Used to List out All User Table Name of a Database
To List out all user table name of a database, just using the query statement as below:SELECT Table_Name
FROM INFORMATION_SCHEMA.Tables
WHERE Table_Type = 'BASE TABLE'
Posted by Wec at 2:31:00 PM 0 comments
Labels: SQL Server
Tuesday, March 11, 2008
Ways to Convert Date to Different Formats in SQL Server 2000
You may want to convert the date into different format that you want. At here, I got example how to convert date to 15 different formats using SQL Query.--'YYYYMMDD'
SELECT CONVERT(CHAR(8), GETDATE(), 112)
--'YYYY-MM-DD'
SELECT CONVERT(CHAR(10), GETDATE(), 23)
--'YYYY-MMM-DD'
SELECT STUFF(CONVERT(CHAR(10), GETDATE(), 23), 6, 2, LEFT(DATENAME(m, GETDATE()), 3))
--'YYMMDD'
SELECT CONVERT(VARCHAR(8), GETDATE(), 12)
--'YY-MM-DD'
SELECT STUFF(STUFF(CONVERT(VARCHAR(8), GETDATE(), 12), 5, 0, '-'), 3, 0, '-')
--'YY-MMM-DD'
SELECT STUFF(STUFF(STUFF(CONVERT(VARCHAR(8), GETDATE(), 12), 3, 2, LEFT(DATENAME(m, GETDATE()), 3)), 6, 0, '-'), 3, 0, '-')
--'MM-DD-YY'
SELECT CONVERT(CHAR(8), GETDATE(), 10)
--'MMDDYY'
SELECT REPLACE(CONVERT(CHAR(8), GETDATE(), 10), '-', SPACE(0))
--'MM/DD/YY'
SELECT CONVERT(CHAR(8), GETDATE(), 1)
--'MM/DD/YYYY'
SELECT CONVERT(CHAR(10), GETDATE(), 101)
--'DD-MM-YY'
SELECT REPLACE(CONVERT(CHAR(8), GETDATE(), 3), '/', '-')
--'DD-MMM-YY'
SELECT STUFF(REPLACE(CONVERT(CHAR(8), GETDATE(), 3), '/', '-'), 4, 2, LEFT(DATENAME(m, GETDATE()), 3))
--'DDMMYY'
SELECT REPLACE(CONVERT(CHAR(8), GETDATE(), 3), '/', SPACE(0))
--'DD/MM/YY'
SELECT CONVERT(CHAR(8), GETDATE(), 3)
--'DD/MM/YYYY'
SELECT CONVERT(CHAR(10), GETDATE(), 103)
Hope that is one the format you want. If not, please write a comment with the format date you want. I will try my best to help you. Thanks.
Posted by Wec at 5:23:00 PM 2 comments
Labels: SQL Server
Monday, March 10, 2008
Gets IP Address of Server PC using C# (ASP .NET 1.1)
The function below is used to get the IP Address of Server. The System.Net
namespace is needed for this function. This is because IPHostEntry
and IPAddress
are class in System.Net
namespace. Beside this, GetHostName()
function also belong to System.Net.Dns
.
public string GetIPAddress()
{
string strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; return ipAddress.ToString();
}
Posted by Wec at 11:39:00 AM 1 comments
Labels: .NET Programming, ASP .NET 1.1, C#.NET