Saturday, September 14, 2013
Sunday, June 30, 2013
Web Application VS Web Site in Visual Studio
What is the difference between Web Application and Web Site in Visual Studio?
Web Application VS Web Site
In Visual Studio we can create Web Application projects or Web Site projects by choosing New Project or New Web Site. Each type of project has advantages and disadvantages. It is much necessary to select the appropriate project type. Because, it is not practical to convert one project type to the other.
Web Application
|
Web Site
|
It creates a Visual Studio project file (.csproj or .vbproj) that store the information of all the files in a project.
|
It does not create any Visual Studio project file (.csproj or .vbproj). All the files in a project stay in folder structure.
|
Every page has .aspx, .aspx.cs, .aspx.designer.cs files.
|
Every page has .aspx, .aspx.cs files.
|
We can create MVC application.
|
We cannot create MVC application.
|
We cannot edit individual files after deployment without recompiling.
|
We can.
|
Creates pre-compiled pages.
|
Creates code behind pages that are compiled when page is requested
|
If we make a single change in one page we need to re-compile the entire sites. We need to deploy the entire sites.
|
If we make any change we don’t need to re-compile entire sites. We need not to deploy the entire sites. We will only upload the changes pages.
|
It does not support multi programming languages.
|
It supports multi programming languages.
|
All the files are compiled into a single assembly file.
|
All the files are not compiled into a single assembly file. When we publish the site every time a dll file is created for each file and its name is auto generated.
|
For more please visit cybarlab.com
Monday, March 18, 2013
Run C Sharp Console Application using Windows Scheduler
Run C# Console Application using Windows Scheduler
Some tome we need to do a task periodically. Suppose
we want to transfer file from one location to another location periodically.
For this we can developed an windows service or console
application. Here I will discuss about windows console application and will run
it form windows task scheduler
Creation of C# Console Application
First create a console application in C#. Write your
desired code to fulfill your requirements. Then compile it. After compilation some
dll or exe files will be generated in Bin folder. Then make a Task in Windows
Scheduler by using this dll or exe files.
Creation of Windows Scheduler Task
- Log on as administrator.
- Make a folder [FilePuller] and copy all the dll or exe files of your application from Bin folder.
- Open Task Scheduler by either typing "task" into the Start Menu search bar, or by opening All Programs - Accessories - System Tools.
- You will find 'Create Basic Task’ and ‘Create Task..’. You can follow any one of them. Here I will discuss 'Create Basic Task’.
- Select 'Create Basic Task' from the right hand pane and the 'Create Basic Task Wizard will open.
- Type a 'Name' and 'Description' [FilePuller] for your new task and click next.
- Select when you would like the event/task to run and click next. I am selecting daily.
- Select exact time when you want to run the application and click next.
- Select action and click next. I am selecting here Start a program.
- Click ‘Browse’ and select the exe file form the [FilePuller] folder and click next.
- Click Finish.
New task has been created and will run at the
specified time. Click ‘Refresh’ and you will find your Task [FilePuller]. This
Task will copy file form one location to another location. From the above steps
you can make any application automated.
You can change you task settings at any time, just
double-click the new task.
If you wish to delete the task you can just click
the 'Delete' button in the right hand pane.
Tuesday, February 19, 2013
Standard Naming Convention for ASP.NET and C#
Standard Naming Convention for ASP.NET and C#
In programming language naming convention have great
benefits to reduce the effort needed to read and understand source code. It provides
better understanding in case of reuse code after a long interval of time. It is
an initial step for beginner to learn any programming language. It is a very
important element. Here I have explained some criteria about naming convention
for programmer.
There are different types of naming casing style. First
let’s understand different types of casing styles.
- Camel Case (camelCase): First letter of the word is
lower case and then each first letter of the part of the word is upper case.
Example: numberOfDays
- Pascal Case (PascalCase): First letter of the word
is upper case and then each first letter of the part of the word is upper case.
Example: DataTable
- Underscode Prefix (_underscore): The word begins
with underscore singe and for the rest of the word use camelCase rule. Example:
_strFirstName
- Hungarian Notation: First letter of the word is
about its data type and rest of the word is camelCase. Example: iStudentNumber
(i=integer)
- Uppercase: All letters of the word are uppercase.
Example: ID, PI
Naming Convention Guidelines
1. Private Variables
Use Camel Case for private variables.
Example: studentName
2.
Local Variables
Use Camel Case for local variables.
Example: studentName
3.
Method
Use Pascal Case for method name.
Example: public string
HelloWorld { ... }
4.
Property/ Enumerations
Use Pascal Case for
Property/Enumerations.
Example: StudentName,
StudentAddress
5.
Parameter
Use Camel Case for parameter
Example: void
SayHello(string studentName)
{
string fullMessage = "Hello " +
studentName;
}
6.
Namespace
Use Pascal Case for namespace. Use the company name followed by the
technology name and optionally the feature and design as follows:
CompanyName.TechnologyName[.Feature][.Design]
Example: CybarLab.Database,
System.Web.UI, System.Windows.Forms
7.
Class
Use Pascal Case for class
Example:
public class HelloWorld
{ ... }
8.
Interface
Use Pascal Case for interface. Use
Prefix “I” with interface name, to indicate that the type is an interface. Do
not use the underscore character (_).
Example: IServiceProvider,
IMemberDirectory
9.
Event
Use Pascal Case for event.
Example: protected void
Button1_Click(object sender, EventArgs e) {…….}
10.
Exception
Visual Studio .NET use “e” parameter for the event
parameter to the call. To avoid conflicting please use “ex" as a standard
variable name for an exception object.
Example:
catch (Exception ex)
{
// Handle Exception
}
11.
Constant
Use uppercase for constant variables with words
separated by underscores. It is recommended to use a grouping naming schema.
Example (for group AP_WIN):
AP_WIN_MIN_WIDTH, AP_WIN_MAX_WIDTH
12. Avoid
abbreviations longer than 5 characters
13. Avoid
using abbreviations unless the full name is excessive
Example:
Good: string student
Not good: string stu
14. Use
meaningful, descriptive words for naming variables
15. All
member variables must use Underscore Prefix so that they can be identified from
other local variables names
16. Avoid
naming conflicts with existing .NET Framework namespaces or types
17. Do
not include the parent class name within a property name
Example
Good: Customer.Name
Not good: Customer.CustomerName
18. Use
Pascal Case for file names
19. Method
name should tell you what it does
20. A
method should do only “one job”. Do not combine multiple jobs in one method
even if those jobs have very few lines of code.
Naming Convention of ASP.NET Control
In general, naming ASP.NET controls is made using
Camel Case naming convention, where the prefix of the name is the abbreviation
of the control type name.
ASP.NET Control
|
Abbreviation
|
Standard Controls
|
|
Button
|
btn
|
CheckBox
|
cbx
|
CheckBoxList
|
cbxl
|
DropDownList
|
ddl
|
FileUpload
|
fu
|
HiddenField
|
hdn
|
Hyperlink
|
lnk
|
Image
|
img
|
ImageButton
|
ibtn
|
Label
|
lbl
|
LinkButton
|
lbtn
|
ListBox
|
lb
|
Literal
|
lit
|
MultiView
|
mv
|
Panel
|
pnl
|
PlaceHolder
|
ph
|
RadioButton
|
rbo
|
RadioButtonList
|
rbol
|
Table
|
tbl
|
TextBox
|
txt
|
View
|
v
|
Data Controls
|
|
DataList
|
dtl
|
DataPager
|
dp
|
DetailsView
|
dtv
|
EntityDataSource
|
ets
|
FormView
|
fv
|
GridView
|
gv
|
LinqDataSource
|
lds
|
ListView
|
lv
|
ObjectDataSource
|
ods
|
QueryExtender
|
qe
|
Repeater
|
rpt
|
SiteMapDataSource
|
smd
|
SqlDataSource
|
sds
|
XmlDataSource
|
xds
|
Validation Controls
|
|
CompareValidator
|
cpv
|
CustomValidator
|
ctv
|
RangeValidator
|
rv
|
RegularExpressionValidator
|
rev
|
RequiredFieldValidator
|
rfv
|
ValidationSummary
|
Vs
|
In summery we can say that use Pascal Case for
anything which is public. Try to avoid underscore “_” or hyphen “-”.
For more please visit cybarlab.com
Subscribe to:
Posts (Atom)