- Define a constructor method in your UserControl class
public partial class MyUserControl : System.Web.UI.UserControl
{
public MyUserControl()
{
}
public MyUserControl(string param1, int param2, bool param3)
{
// Do anything you whant for your parameters here
textbox1.Text = param1;
.....
}
}
- Define our customize LoadControl() method so that the parameters can be pass into the UserControl
private UserControl LoadUserControl(string controlPath, params object[] parameters)
{
List<Type> paramTypes = new List<Type>();
foreach(object param in parameters)
{
paramTypes.Add(param.GetType());
}
Page page = new Page();
UserControl uc = page.LoadControl(controlPath) as UserControl;
ConstructorInfo ci = uc.GetType().BaseType.GetConstructor(paramTypes.ToArray());
if(ci == null)
{
throw new MemberAccessException( "The requested constructor was not found on : "
+ uc.GetType().BaseType.ToString());
}
else
{
ci.Invoke(uc, parameters);
}
return uc;
}
- Now you can use the LoadControl as below to pass the parameters to the UserControl
// Initiallize the UserControl with it parameters .....UserControl myControl = LoadControl(
"MyUserControl.ascx"
, "This is value of param1"
, 1234, true);
Friday, October 9, 2009
How to pass parameters to UserControl
Friday, September 25, 2009
身份證字號說明
身份證字號 共有十碼, 以下是位置說明,僅供各位參考
N1 N2 N3 N4 N5 N6 N7 N8 N9 N10
戶籍 性別 ~流~~~~~~~~水~~~~~~~~~~~碼~
代表說明
戶籍代表字母
A台北市 B台中市 C基隆市 D台南市 E高雄市 F台北縣
G宜蘭縣 H桃園縣 I嘉義市 J新竹縣 K苗栗縣 L台中縣
M南投縣 N彰化縣 O新竹市 P雲林縣 Q嘉義縣 R台南縣
S高雄縣 T屏東縣 U花蓮縣 V台東縣 W金門縣 X澎湖縣
Y陽明山 Z連江縣
英文字母代表的數字
A=10 B=11 C=12 D=13 E=14 F=15 G=16 H=17 I=34 J=18 K=19 L=20
M=21 N=22 O=35 P=23 Q=24 R=25 S=26 T=27 U=28 V=29 W=32 X=30
Y=31 Z=33
性別代表數字
1:男性
2:女性
步驟
1. 查出英文字所代表的數字
再將所查出的數字 "十位數+個位數x9"
例: 台北市=10
1 + 0x9 =1
台中市=11
1 + 1x9 =10
2. N2x8+N3x7+N4x6+N5x5+N6x4+N7x3+N8x2+N9+N10
將流水碼依序乘8765432
一個個乘.乘完要加起來. (別忘了先乘除後加減)
例: 123456789
1x8+2x7+3x6+4x5+5x4+6x3+7x2+8+9
3.將步驟1 和步驟2 的兩個數加起來除以10.
例:步驟1 台北計算結果 =1
步驟2 1x8+2x7+3x6+4x5+5x4+6x3+7x2+8+9 =129 (1+129)/10
除10後看看是否可以整除.如可以整除即為正確的
身份證字號. 如無法整除即是錯誤的身份證字號
(1+129)/10 = 13 => 可以整除.正確
N1 N2 N3 N4 N5 N6 N7 N8 N9 N10
戶籍 性別 ~流~~~~~~~~水~~~~~~~~~~~碼~
代表說明
戶籍代表字母
A台北市 B台中市 C基隆市 D台南市 E高雄市 F台北縣
G宜蘭縣 H桃園縣 I嘉義市 J新竹縣 K苗栗縣 L台中縣
M南投縣 N彰化縣 O新竹市 P雲林縣 Q嘉義縣 R台南縣
S高雄縣 T屏東縣 U花蓮縣 V台東縣 W金門縣 X澎湖縣
Y陽明山 Z連江縣
英文字母代表的數字
A=10 B=11 C=12 D=13 E=14 F=15 G=16 H=17 I=34 J=18 K=19 L=20
M=21 N=22 O=35 P=23 Q=24 R=25 S=26 T=27 U=28 V=29 W=32 X=30
Y=31 Z=33
性別代表數字
1:男性
2:女性
步驟
1. 查出英文字所代表的數字
再將所查出的數字 "十位數+個位數x9"
例: 台北市=10
1 + 0x9 =1
台中市=11
1 + 1x9 =10
2. N2x8+N3x7+N4x6+N5x5+N6x4+N7x3+N8x2+N9+N10
將流水碼依序乘8765432
一個個乘.乘完要加起來. (別忘了先乘除後加減)
例: 123456789
1x8+2x7+3x6+4x5+5x4+6x3+7x2+8+9
3.將步驟1 和步驟2 的兩個數加起來除以10.
例:步驟1 台北計算結果 =1
步驟2 1x8+2x7+3x6+4x5+5x4+6x3+7x2+8+9 =129 (1+129)/10
除10後看看是否可以整除.如可以整除即為正確的
身份證字號. 如無法整除即是錯誤的身份證字號
(1+129)/10 = 13 => 可以整除.正確
Wednesday, September 16, 2009
Clear Drop Down List of Recent Connection From SQL Server Management Studio
SQL Server Management Studio 2017 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\14.0\SqlStudio.bin
SQL Server Management Studio 2016 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\13.0\SqlStudio.bin
SQL Server Management Studio 2014 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin
SQL Server Management Studio 2012 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
SQL Server Management Studio 2008 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
SQL Server Management Studio 2005 delete the file – same as above answer but the Vista path.
C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.datIn fact there's a way to delete all the history info in the dialog fields.
For SQL Server 2005:
C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
If you can not find mru.dat at above location look for mru.dat in following folder.
C:\Documents and Settings\[user]\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM\mru.dat
For SQL Server 2008:
C:\Documents and Settings\<user>\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
If you can not find mru.dat at above location look for mru.dat in following folder.
C:\Documents and Settings\[user]\Application Data\Microsoft\Microsoft SQL Server\100\Tools\ShellSEM\mru.dat
If you are using VISTA OS instead of XP OS. Replace C:\Documents and Settings\[user]\Application Data\Microsoft\ with
C:\Users\\AppData\Roaming\Microsoft\ and it should work.
Make sure to take note down any IP address of SQL Server you may need in future.
Reference : Pinal Dave (http://www.SQLAuthority.com)
Saturday, September 5, 2009
How to reset MS SQL Server IDENTITY
If the table is new create you can use this to reset the identity
DBCC CHECKIDENT (yourtable, reseed, seed_value)
If you delete that data in the table u can use
DBCC CHECKIDENT (yourtable, reseed, 0)
DBCC CHECKIDENT (yourtable, reseed, seed_value)
If you delete that data in the table u can use
DBCC CHECKIDENT (yourtable, reseed, 0)
Thursday, August 27, 2009
How to Install/UnInstall COM Componets
If the COM file is a executive .exe file.Excute the file with a argument as below:
-Service // Install .exe COM file as a windows service.
-UnregServer // Uninstall .exe COM componet.
-RegServer // Install .exe COM file as a windows COM componet.
-UnregServer // Uninstall .exe COM componet.
-RegServer // Install .exe COM file as a windows COM componet.
If the COM file is a DLL file, suppose the file name is mycom.dll.
regsvr32 mycom.dll // To install dll COM
regsvr32 /u mycom.dll // Run regsvr32 with argument /u to uninstall the dll COM
regsvr32 /u mycom.dll // Run regsvr32 with argument /u to uninstall the dll COM
dcomcnfg // This tool can see the all DCOM componets has installed in the system.
The Installutil.exe is a tool for .NET componets registration
Here some argument options
| Option | Description |
|---|---|
| /h[elp] | Displays command syntax and options for the tool. |
| /help assemblypath | Displays any additional options recognized by individual installers within the specified assembly. |
| /logFile=[filename] | Specifies the name of the log file where install progress is recorded. The default is assemblyname.InstallLog. |
| /logToConsole={true|false} | If true, displays output to the console. If false (the default), suppresses output to the console. |
| /showCallStack | Prints the call stack to the log if an exception occurs at any point during installation. |
| /u[ninstall] | Uninstalls an assembly. Unlike other options, /u applies to all assemblies regardless of where it appears on the command line. |
| /? assemblypath | Displays any additional options recognized by individual installers within the specified assembly. |
| /? | Displays command syntax and options for the tool. |
The SC.exe is a Windows SDK tool
The SC.exe can be used to Query, Install, Uninstall and Setting Windows Service and Windows Hardware Drivers.
How to use it go ask google!
Friday, July 17, 2009
How to config network in Solaris 10
Changes Static IP Address and Host Name
The sample below shows how to uses ipconfig change static IP address to 192.168.0.10 with netmask 255.255.255.0
- ifconfig vfe0 unplumb
- ifconfig vfe0 plumb 192.168.0.10 netmask 255.255.255.0 up
Config host name for ethernet card
/etc/hostname.vfe0
solaris10
Config network mapping for IP address and host name (hostname of Ethernet card)
the hosts file format of each line is:
IP-address official-host-name nicknames....
the nicknames can be optional.
/etc/hosts
127.0.0.1 localhost loghost
192.168.0.xxx solaris10
/etc/netmasks
192.168.0.xxx 255.255.255.0
Config Gateway
/etc/defaultrouter
192.168.0.1
Config DNS
1. Specify DNS Server
/etc/resolv.conf
nameserver 168.95.192.1
nameserver 168.95.192.2
2. In order to enable DNS resolve, change the line in nsswitch.conf as below
/etc/nsswitch.conf
hosts: files dns
inodes: files dns
Tuesday, July 7, 2009
How to uses callback function for C++
// This is a callback function sample without parameter.
void callbackProc1()
{
printf("this is a call back 1..\r\n");
}
void callbackProc1()
{
printf("this is a call back 1..\r\n");
}
// This is a callback function sample with 2 parameters
bool callbackProc2(int nSize, char* pszName) {
printf("this is a call back 2..\r\nSize is:%d pszName is:%s \r\n", nSize, pszName);
return true;
}
bool callbackProc2(int nSize, char* pszName) {
printf("this is a call back 2..\r\nSize is:%d pszName is:%s \r\n", nSize, pszName);
return true;
}
// This function invoke callback function as a parameter to it
void test1(void(*p)(void))
{
p();
}
void test1(void(*p)(void))
{
p();
}
// This function invoke a callback function with 2 parameters
void test2(bool(*p)(int, char*), int param1, char* param2)
{
if(p(param1, param2))
{
printf("the callback func return TRUE.......\r\n");
}
}
void test2(bool(*p)(int, char*), int param1, char* param2)
{
if(p(param1, param2))
{
printf("the callback func return TRUE.......\r\n");
}
}
void main()
{
// this is a sample to demonstrate how to invoke a callback function without parameter
// the callback function name is a memory address reference to callback function.
test1(callbackProc1);
// this is a sample shows how to invoke a callback functions with two parameters
test2(callbackProc2, 999, "johnrock");
}
Subscribe to:
Posts (Atom)