Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

.NET coding tips

by the3factory 3/10/2008 6:41:00 AM
The following are some useful little tips for myself.

The @ symbol in C#
Instead of writting double \\s in a file or folder path,
prefacing the string with "@", as following:

string s = @"c:\webs\aspnet\csharp";

Prefacing a string with "@" also enables you write a
string as the following without fussing around with
stringing lines together.

string s = @"Line 1
Line2

Line4";


Double Quote Symbol in a String

For double quote character " to work in a string literal,
the way to go is to use two consecutive double-quotes, as such:

s = @"She said: ""Hello""");

The above will be output as: She said "Hello".


~ In ASP .NET Controls;

This character references the application's root.
Many ASP.NET server controls allow for this type of syntax.

Example syntax:

Returns the correct path based on the application's root.
For example, if the application was rooted at the virtual
directory Foo, the return value would be
<code>/Foo/Images/Skyline.jpg...</code>



Server-Side Comment Syntax: <%-- Comment --%>
Server-side comments enable page developers to prevent server code (including server controls) and static content from executing or rendering. The following sample demonstrates how to block content from executing and being sent down to a client. Note that everything between <%-- and --%> is filtered out and only visible in the original server file, even though it contains other ASP.NET directives.


<%--
<asp:calendar id="MyCal" runat=server/>
<% for (int i=0; i<45; i++) { %>
Hello World <br>
<% } %>
--%>


<%--
<asp:calendar id="MyCal" runat=server/>
<% For I=0 To 44 %>
Hello World <br>
<% Next %>
--%>


<%--
<asp:calendar id="MyCal" runat=server/>
<% for (var i:int=0; i<45; i++) { %>
Hello World <br>
<% } %>
--%>

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0