Tuesday, January 22, 2013
tsql add default constraint
IF NOT EXISTS(select * from sys.DEFAULT_CONSTRAINTS where NAME like 'def_myconstraint1%')
BEGIN
ALTER TABLE mytable1
ADD CONSTRAINT def_myconstraint1 DEFAULT 1 FOR mycolumn1
END
GO
Posted by
SF
at
2:32 pm
0
comments
Friday, January 18, 2013
css center a div
tried to use text-align:center didnt work, the correct way is:
width: 10240px ; margin-left: auto ; margin-right: auto ;
Posted by
SF
at
1:04 pm
0
comments
Saturday, January 12, 2013
asp.net web application update web.config SMTP settings in global.ascs application_start():
asp.net web application update web.config SMTP settings in global.ascs application_start():
Posted by
SF
at
9:56 pm
0
comments
Wednesday, January 09, 2013
prevent double click on asp.net button control
headache solved after search and search and search for solutions:
Posted by
SF
at
1:14 pm
0
comments
Wednesday, December 26, 2012
asp.net Response.RedirectToRoute issue
- The parameter is not given. e.g. Response.RedirectToRoute("My Home Page");
- The parameter as null value. e.g. Response.RedirectToRoute("My Home Page", new {myid = null});
- The parameter as null value. e.g. Response.RedirectToRoute("My Home Page", new {myid = string.empty});
Posted by
SF
at
11:03 pm
0
comments
regular expression for character range
regular expression for character range:
e.g. between 1 and 500:
^.{1,500}$
Posted by
SF
at
7:46 pm
0
comments
Thursday, December 20, 2012
fix asp.net checkboxlist wierd layout
on one page my checkboxlist shows up correctly, on another it never does. After hours of trying I figured this out: assign CheckBoxList class to your css class of the checkboxlist, play with the properties inside the class will help you fix the issues.
.CheckBoxList input
{
margin-left: -10px;
}
.CheckBoxList td
{
padding-left: 10px;
width:80%;
}
Posted by
SF
at
3:17 pm
0
comments
t-sql change a column from nullable to not null and add default value it
--1.make sure all records have a value in the column
update [TableName]
SET [ColumnName] = [Default Value]
--2. change the column to not null
ALTER TABLE [TableName]
ALTER COLUMN [ColumnName] [data type] NOT NULL
GO
--3. add default value constraint to the column
ALTER TABLE [TableName] WITH NOCHECKADD CONSTRAINT [DF_DefaultName] DEFAULT [Default Value] FOR [ColumnName]
GO
Posted by
SF
at
11:57 am
0
comments
Wednesday, December 05, 2012
jquery to check if an asp.net checkbox control is selected or unselected:
//your code here
}
Posted by
SF
at
4:31 pm
0
comments
Saturday, November 24, 2012
Telerik OpenAccess Service works locally but not hosted
I have 3 projects, one with the entity model, another one with the OData v3 service generated from the entity model, the third one is an asp.net web application.
During local development the service reference I added into the web app is from same solution: http://localhost:55001/MyModelService.svc
After everything was successfully tested I then published the service project and hosted it on a third party hosting service. I was able to browse the service successfully by going: http://service.myapp.com/MyService.svc
I then re-added the existing service reference into my web app with the remote url shown above, published the web app on another hosting service.
When I load up the web app I got an error:
DataServiceQueryException was unhandled by user code
An error occurred while processing this request.
The issue turned out to be really fundamental which I missed out through all my WCF learnings: the cross domain policy xml!
The solution is to add a clientaccesspolicy.xml into the OpenAccess Service WCF app root folder with the following content:
Posted by
SF
at
1:43 am
0
comments
Labels: wcf data service cross domain policy telerik orm service odata v3
Wednesday, August 22, 2012
Friday, August 03, 2012
MS Office EXCEL 2010 the safest way to open .csv file and maintain leading zeros
Step 1:
Open EXCEL, click on tab "Data", select "From Text".
Step 2:
Browse to your local file folder and open the .csv file.
Step 3:
In the "Text Import Wizard - Step 1 of 3" popup, select "Delimited" and click on "Next".
Step 4:
In the "Text Import Wizard - Step 2 of 3" popup, select "Comma", un-select all other options, and click on "Next".
Step 5:
In the "Text Import Wizard - Step 3 of 3" popup, in "Data Preview" click to select the column you want to maintain leading zeros, then select "Text" in "Column data Format", now click on "Finish".
Step 6:
In the "Import Data" popup click on "OK".
Now you can see all leading zeros in EXCEL!
Posted by
SF
at
11:11 am
0
comments
Thursday, July 12, 2012
get selected values form a checkboxlist c# asp.net web application
List
Posted by
SF
at
4:15 pm
0
comments
Wednesday, June 20, 2012
asp.net c# write to txt file
string path = HttpContext.Current.Server.MapPath("~/xxxxxxxx.txt");
if (!System.IO.File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = System.IO.File.CreateText(path))
{
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
sw.WriteLine("------------------------Some explanation of the purpose of this file-----------------------------");
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
}
}
using (StreamWriter sw = System.IO.File.AppendText(path))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
sb.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
sb.AppendLine("WHEN: " + DateTime.Now.ToString());
sb.AppendLine("WHO: " + GetCurrentUser());
IPHostEntry host;
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
sb.AppendLine("WHERE: " + ip.ToString());
break;
}
}
sb.AppendLine("WHAT: " + errorMsg);
sb.AppendLine();
sb.AppendLine();
sb.AppendLine();
sw.WriteLine(sb.ToString());
}
Posted by
SF
at
11:26 am
0
comments
Tuesday, June 19, 2012
.NET Web Application install default SqlMembershipProvider schema
find and run the following executable inside "%Windows\Microsoft.NET\[framework number]\[version number]\"
aspnet_regsql.exe
Posted by
SF
at
11:34 pm
0
comments
Friday, June 15, 2012
RadGrid ItemCommand Find Control
if the control you are looking for is a button:
((Button)e.CommandSource)
if the control you are looking for is a label:
((Label)e.CommandSource)
Posted by
SF
at
3:51 pm
0
comments
Thursday, June 14, 2012
RadWindow Resize by Percentage
var width = $telerik.$(window).width() * 0.8;
var height = $telerik.$(window).height() * 0.95;
ExpWindow.setSize(width, height);
ExpWindow.center();
Posted by
SF
at
4:30 pm
0
comments
StimulSoft Report Web Designer Save Report
protected void
StiWebDesigner1_SaveReport(object sender,
Posted by
SF
at
3:20 pm
0
comments