Naveen P.N

Just another Blog to play with programming

Project-Based Development and Projectless-Based Development

leave a comment »

Introduction

Web Project can be developed of two types

a)      Projectless Based Development

b)      Project Based Development or web project

Project less Based Development

Creating websites of this form is called project less applications. It has its own advantages over Project Based Development.

1

The advantages include

a) It simplifies deployment: We can simply copy the files in the website directory to the web server.

b) It simplifies file management: Adding , deleting and  moving files  is very easy u can just delete, add or move a web page ,there is no need to go through Visual Studio or edit the project file.

c) It simplifies team collaboration: Each team can work independently on different pages.

d)     It simplifies debugging: Creating a web project ,you must recompile the entire application when you change a single file With project less development, each

page is compiled separately, and the page is only compiled when you request it for the first time.

Project Based Development or Web Project

Creating project of this form is called Project Based Development or simply Web Project. If we create application of this form Visual Studio generates a number of extra files, including .csproj and .csproj.user project files and .sln solution file.

2

3

When you build your application, Visual Studio generates temporary files, which is places in the Obj subdirectory, and one or more .pdb files (in the Bin subdirectory) with debugging symbols. None of these files should be deployed to the web server when your web application is complete. Furthermore, none of the C# source code files (files with the extension .cs) should be deployed, because Visual Studio recompiles them into a DLL assembly.

However both are same once they are deployed to the web server,but they differ in their structure .The difference include

a)      Compilation: Web projects are compiled by Visual Studio and not ASP.NET when they run. All the web pages classes is combined into a single assembly that has the name of web project(like web project.dll);

4

b)      Code-behind: The web pages also uses code behind file however they include one additional file with an extension .aspx.designer.cs.

5

c)      Assembly references: In a project less website ,all the assembly references are recorded in the web.config file

Other posts

* Using C# and VB classed together in the App_Code folder :

*   ASP.NET Application Folders

*   Creating Dynamic Linking Library using ASP.NET

*   VB Style Calendar in ASP.NET

* Sending SMS from ASP.NET Application

*   View State

*   What is the difference between Server.Transfer and Response.Redirect?

*   Text to Speech in ASP.NET

*  Using C# and VB classed together in the App_Code folder :
http://naveenpn.wordpress.com/2009/10/23/using-c-and-vb-classed-together-in-the-app_code-folder/
*  ASP.NET Application Folders
http://naveenpn.wordpress.com/2009/10/08/asp-net-application-folders/
*  Creating Dynamic Linking Library using ASP.NET
http://naveenpn.wordpress.com/2009/10/05/creating-dynamic-linking-library-using-asp-net/
*  VB Style Calendar in ASP.NET
http://naveenpn.wordpress.com/2009/09/27/vb-style-calendar-in-asp-net/
*  Sending SMS from ASP.NET Application
http://naveenpn.wordpress.com/2009/09/27/sending-sms-from-asp-net-application/
* View State
http://naveenpn.wordpress.com/2009/09/13/view-state/
*  What is the difference between Server.Transfer and Response.Redirect?
http://naveenpn.wordpress.com/2008/06/11/aspnet/
*  Text to Speech in ASP.NET
http://naveenpn.wordpress.com/2009/08/27/text-to-speech-in-asp-net/
AJAX Control Toolkit
——————–
*  Traditional Page Updates VS AJAX Page Updates
http://naveenpn.wordpress.com/2009/08/29/traditional-page-updates-vs-ajax-page-updates/

Written by Naveen P.N

October 23, 2009 at 1:09 am

Posted in ASP.NET

Using C# and VB classed together in the App_Code folder

with one comment

Introduction

Hi in this article I demonstrate how to use two different classes together in ASP.NET application. As we know ASP.NET application supports more than 24 languages we don’t know how to use two different languages in one single application. One important thing mixing of classes coded in different languages is not allowed with default settings. You can, however, configure your web.config file to get this done. This article is going to explain you that how one can do that.

Creating Sub folders and classes

Create two separate folders one for C# code and one for VB code .Without modifying web.config file if we compile we get an error.

23

231

To solve this we should modify web.config file.

23b

protected void CSharpbtn_Click(object sender, EventArgs e)

{

int a = MathematicsClassCSharp.addition(2, 2);

Label1.Text = a.ToString();

}

protected void VBbtn_Click(object sender, EventArgs e)

{

int a1 = MathematicsClassVB.addition(1,1);

Label1.Text = a1.ToString();

}

Written by Naveen P.N

October 23, 2009 at 12:24 am

Posted in ASP.NET

Disabling Copy Paste in a TextBox

leave a comment »

Hi this article is more or less similar to the last article “Restricting the mouse click on a web page” the logic is the same with little intelligence. In this article I will disable the Copy, Paste and Ctrl Functionality of a TextBox, before reading this article I request you to please check the previous article for better understanding.

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>
<script type=”text/javascript” src=”Restrict Copy and Paste.js”>
</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<pre>
Right Click Disabled   : <asp:TextBox ID=”TextBoxCopy” runat=”server”
onMouseDown=”DisableRightClick(event)”>
</asp:TextBox>
Ctrl Key Disabled      : <asp:TextBox ID=”TextBox2″ runat=”server”
onKeyDown=”return DisableCtrlKey(event)”>
</asp:TextBox><br />
Copy and Paste Disabled: <asp:TextBox ID=”TextBox1″ runat=”server”
oncopy=”return false” onpaste=”return false”                    oncut=”return false”>       </asp:TextBox>
</pre>
</form>
</body>
</html>

Restrict Copy and Paste.aspx

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Untitled Page</title>

<script type=”text/javascript” src=”Restrict Copy and Paste.js”>

</script>

</head>

<body>

<form id=”form1″ runat=”server”>

<pre>

Right Click Disabled   : <asp:TextBox ID=”TextBoxCopy” runat=”server”

onMouseDown=”DisableRightClick(event)”>

</asp:TextBox>

Ctrl Key Disabled      : <asp:TextBox ID=”TextBox2″ runat=”server”

onKeyDown=”return DisableCtrlKey(event)”>

</asp:TextBox><br />

Copy and Paste Disabled: <asp:TextBox ID=”TextBox1″ runat=”server”

oncopy=”return false” onpaste=”return false” oncut=”return false”> </asp:TextBox>

</pre>

</form>

</body>

var buttonright = 2; // button right

function DisableRightClick(event)

{

//For mouse right click

if (event.button==buttonright)

{

alert(“Right Clicking not allowed!”);

}

}

</html>

Restrict Copy and Paste.js

function DisableCtrlKey(e)

{

var code = (document.all) ? event.keyCode:e.which;

var message = “Ctrl key functionality is disabled!”;// look for CTRL key press

if (parseInt(code)==17)

{

alert(message);

window.event.returnValue = false;

}

}


text1


text2


Download Code with Article

Written by Naveen P.N

October 8, 2009 at 11:19 pm

Posted in ASP.NET

Restricting Mouse Click on a web page

leave a comment »

Hi in this article I will explain how to restrict mouse click on a web page ,so that user will not save images just like orkut which restrict user from saving images.Actually this idea I got from my friends project whose one of the module was restricting user from mouse click.I though to share the small snippet with you people ……….check out and please give your valuable suggestion.

Restrict Mouse Right Click on a web page1

The trick is very simple ,it is all done with little JavaScript .

DisableRightClick.js
DisableRightClick.js

document.onmousedown = mouseDown;

var buttonright = 2; // button right

var msg =“Right Click is not Allowed”;

function mouseDown(e)

{

if (event.button==buttonright)

{

alert(msg);

}

}

DisableRightClick.aspx

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title>Untitled Page</title>

<script type=”text/javascript” src=”DisableRightClick.js.js”>

</script>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

</div>

</form>

<p>

<img alt=”" src=”images/naveen.gif” style=”width: 107px; height: 118px” /></p>

</body>

</html>


Restrict Mouse Right Click on a web page2

Dowlnload Code with Article

Written by Naveen P.N

October 8, 2009 at 10:58 pm

ASP.NET Application Folders

leave a comment »

Hi in this article I will explain application folders in ASP.NET 2.0.You would have observed when you create ASP.NET Application you can add folders called application folders, these are special folders in asp.net each one has special purpose and meaning. ASP.NET 2.0 has the capability to automatically precompiled ASP.NET application whereas in 1.0 and 1.1 frameworks everything was compiling into DLL. This is not the case in ASP.NET 2.0 framework this is because of its defined folder structure Let us now examine the usage of each folder in detail.
There are 6 folders which can be added
a) \App_Code
b) \App_Data
c) \App_Themes
d) \App_GlobalResources
e) \App_localResources
f) \App_WebReferences
g) \App_Browsers

Hi in this article I will explain application folders in ASP.NET 2.0.You would have observed when you create ASP.NET Application you can add folders called application folders, these are special folders in asp.net each one has special purpose and meaning. ASP.NET 2.0 has the capability to automatically precompiled ASP.NET application whereas in 1.0 and 1.1 frameworks everything was compiling into DLL. This is not the case in ASP.NET 2.0 framework this is because of its defined folder structure Let us now examine the usage of each folder in detail.

There are 6 folders which can be added

a) \App_Code

b) \App_Data

c) \App_Themes

d) \App_GlobalResources

e) \App_localResources

f) \App_WebReferences

g) \App_Browsers

app1
\App_Code

The \App_Code folder is used to store classes, .wsdl (Web Service Description Language), and typed dataset The main use of \App_Code folder is any of the files used in this folder will be available to all the pages in the solutions. One nice thing whenever you place something inside the folder VS 2005 detects this and compiles it if is a class and creates XML web service proxy class (.wsdl).
Add the Calculator class into \App_Code folder, and we will refer this class in our solution

Calculator.cs

public class Calculator

{

public int add(int a, int b)

{

return (a + b);

}

public int sub(int a, int b)

{

return (a – b);

}

}

Default.aspx

protected void Page_Load(object sender, EventArgs e)

{

Calculator calc = new Calculator();

int a = calc.add(1, 2);

Label1.Text = a.ToString();

int b = calc.sub(2, 1);

Label2.Text = b.ToString();

}

We can add class file of both .vb and .cs but little trick as to be done, we have to configure web.config file.

<compilation>

<codeSubDirectories>

<add directoryName=”VB”></add>

<add directoryName=”CS”></add>

</codeSubDirectories>

</compilation>

\App_Data

This folder stores the data stores which is utilized by the application.It can contain Microsoft SQL Express files (.mdf files), Microsoft Access files (.mdb files), XML files, and more.

\App_Themes

Themes can provide common look and feel.It can contain .skin file ,css files , images.All these elements is called as theme

\App_Global Resources

Resource files are nothing but no executable text associated with the program,Typically resources are images,icons ,text and auxillary files.Resource files are  string tables that can serve as data dictionaries for your applications when these applications require changes to content based on things such as changes in culture. You can add Assembly Resource Files (.resx) to this folder, and they are dynamically compiled and made part of the solution for use by all your .aspx pages in the application.

Now let us create two resource files one for English and other for French.

  • English-Resource.resx :It is the default language file using American English

app2

  • French-Resource.resx: The second file is for the same text, but in Finnish Language

app3

When someone with a browser culture of fi-FI invokes the page, he sees the information that comes from this file (French-Resource.resx). Everyone else who comes to the site gets the information that comes from the other file (English-Resource.resx).

protected void Button1_Click(object sender, EventArgs e)

{

Label2.Text = Resources.Resource.Response + “” + TextBox1.Text;

}

By changing the language setting of Internet Explorer you can have the response in that language

app4

App_LocalResource

As \App_GlobalResources folder, is used application-wide. If you are not interested in constructing application-wide resources, then we should go for App_LocalResource whose resources can be used for a single .aspx page only.

\App_WebReference

The App_WebReferences folder is a new name for the previous Web References folder used in previous versions of ASP.NET. Now you can use the \App_WebReferences folder and have automatic access to the remote Web services referenced from your application.

\App_Browsers

The App_Browsers folder holds browser files, which are XML files used to describe characteristics and capabilities of these browsers. We can find a list of globally accessible browser files in the CONFIG\Browsers folder under the installation path. In addition, if you want to change any part of these default browser definition files, just copy the appropriate browser file from the Browsers folder to your application’s \App_Browsers folder and change the definition.

Download Code with Article>

Written by Naveen P.N

October 8, 2009 at 10:35 pm

Posted in ASP.NET

CSS Guide

leave a comment »

Hi here i have deiscussed some of the selectors used in CSS.These are the notes which i have prepared thought of sharing with friends,

Different Types Selectors

a)      Type Selectors

b)      Class Selectors

c)      ID Selectors

d)     Descendent Selectors

e)      Child Selectors

f)       Universal Selectors

g)      Adjacent Sibling Selectors

h)      Attribute Selectors

i)        Pseudo Classes

j)        Pseudo Elements

<html>
<style type=”text/css”>
p
{
background-color: #3399FF;
}
#con
{
background-color: #FFFF66;
}
</style>
<body>
<p>Naveen</p>
<div id=con><p>Sadhana</p></div>
<p>Praveen</p>
</body>
</html>

Type Selectors

Type Selector precedes ID Selector

<html>
<style type=”text/css”>
p
{
background-color: #3399FF;
}
#con
{
background-color: #FFFF66;
}
</style>
<body>
<p>Naveen</p>
<div id=con><p>Sadhana</p></div>
<p>Praveen</p>
</body>
</html>

<html> css1


Class Selectors

<html>
<style >
input.text
{
background-color: #3399FF;
border: medium dotted groove
}
</style>
<body>
<pre>
<input size=”14″ >
<input size=”14″ >
<input size=”14″ >
<input value=”Submit” />
</pre>
</body>
</html>

css2





ID Selectors

 Similarly to class selectors, id selectors enable you to select an element based on the id attribute:
#page-title h1
{
text-align: right;
}
the class selector used a period (.), the id selector relies on a hash (#). In this rule, you selected the h1 element that has an id attribute whose value matches the text after the hash. <html>
<style type="text/css">
#con p
{
background-color: #CCCC99; }
</style>
<body>
<p>Naveen</p>
<div id="con" >
<p>Sadhana</p>
</div>
<p>Praveen</p>
</body>
</html>
Descendant Selectors
 
<html> <style type="text/css"> a { background-color: #FFFF99; }  
li a { background-color: #FF99FF; } </style> <body> <li><a href=" ">Bananas</a></li> <li><a href=" ">Cherries</a></li> </body> </html>
Universal Selector
*
{ font-family: Verdana, Arial, sans-serif; }
Attribute Selector <html> <style type="text/css" > input[type=text] { background-color: #3399FF; border: medium dotted groove } </style> <body> <pre> <input type="text" size="14"> <input type="text" size="14"> <input type="text" size="14"> <input type="button" value="Submit" /> </pre> </body> </html> Using an attribute selector, it would be very easy for you to hone in on all input elements whose type attribute exactly matched “text”:-
input[type=”text”] { border: 1px solid #C00; }
The advantage to this method is that the <input type=”submit” /> element is unaffected, and the border is applied only to the desired text fields. Pseudo Selector
a:link { color: blue; } a:visited { color: purple; } a:hover { color: red; } a:active { color: gray; }
 

Written by Naveen P.N

October 8, 2009 at 10:09 pm

Posted in Web

Embedding Media Player in HTML

leave a comment »

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title></title>
</head>
<body>
<object id=”MediaPlayer1″ width=”180″ height=”200″
classid=”CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95″
codebase=”http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701″
standby=”Loading Microsoft® Windows® Media Player components…”
type=”application/x-oleobject” align=”middle”>
<param name=”FileName” value=”YourFilesName.mpeg”>
<param name=”ShowStatusBar” value=”True”>
<param name=”DefaultFrame” value=”mainFrame”>
<param name=”autostart” value=”false”>
<embed type=”application/x-mplayer2″
pluginspage = “http://www.microsoft.com/Windows/MediaPlayer/”
src=”D:\Documents and Settings\Naveen\My Documents\My Pictures\media.mpeg”
autostart=”false”
align=”middle”
width=”210″
height=”280″
defaultframe=”rightFrame”
showstatusbar=”true”>
</embed>
</object>
</body>
</html>
Hi this is the standard code which is available to embed media player

in html ,it took some time to find the solution.The path of a music

file should be given at a place where the text is blue.

<html>

<head>  <title>Media Player</title></head>

<body>

<object id="MediaPlayer1" width="180" height="200"

        classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"

        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"

        standby="Loading Microsoft® Windows® Media Player components."

        type="application/x-oleobject" align="middle">

       <param name="FileName" value="YourFilesName.mpeg">

       <param name="ShowStatusBar" value="True">

       <param name="DefaultFrame" value="mainFrame">

       <param name="autostart" value="false">

       <embed type="application/x-mplayer2"

             pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"

       src="\\Your Path"  autostart="false" align="middle" width="210" 

       height="280" defaultframe="rightFrame" showstatusbar="true">

    </embed>

</object>

</body>

</html>

Written by Naveen P.N

October 8, 2009 at 9:08 pm

Creating Dynamic Linking Library using ASP.NET

leave a comment »

Hi in this I  article I will  describes what exactly a dll is and how to create a dll file in ASP.NET and use the code.

DLL stands for Dynamic Linking Library which contains code and data which can be used by other application .The main advantage of creating dll is the project can be modularized i.e. the project can be divided into several modules each of the module is linked or called by their respective dll. Windows OS implemented some of the files has dll

1)       ActiveX(.ocx)

2)       Control Panel (.cpl)

3)       Device Driver (.drv)

The main advantage of creating dll’s are

  • The program can be divided into modules so it will easy for a software developer to integrate.
  • It is easy to deploy and installation.
  • Many application can share single copy of dll.

Creating dll using ASP.NET

Let us create a basic class of mathematics which contain some of the maths functions like add,sub,multiply.

Open your Visual Studio and migrate File ->New Project ->Class Library

dll-1

Public Class Class1

Public Function add(ByVal a As Integer, ByVal b As Integer) As Integer

Return a + b

End Function

Public Function subtract(ByVal a As Integer, ByVal b As Integer) As Integer

Return a – b

End Function

Public Function multiply(ByVal a As Integer, ByVal b As Integer) As Integer

Return a * b

End Function

End Class
Once you build a dll file is created ,in the debug folder ,now we will import this dll file into our Windows project.dll2

Create a new Windows Project File -> New Project-> Windows Forms Application.

dll-3

To make the class library available in the client application, a reference to the .dll needs to be added.To do so Select project ->Add Reference ->Browser ->bin \Debug->OK

dll33

Using this code we can access the data which is actually the dll.

Imports Mathematics

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim obj1 As New Class1

Dim result As Integer

result = obj1.add(TextBox1.Text, TextBox2.Text)

MessageBox.Show(“” + result.ToString)

End Sub

End Class
Download

Written by Naveen P.N

October 5, 2009 at 1:17 am

My Documents folder missing in My Computer

leave a comment »

When you open the My Computer screen and your Documents folder is missing but all the other users folders are there try this tweak.

STEP 1:

START >  RUN > REGEDIT >

HKEY_LOCAL_MACHINE / Software / Microsoft / Windows / Current Version / Explorer / DocFolderPaths

Once you click the DocFolderPaths folder you should see all the user’s folders.

STEP 2:

Add a new string value

mydocuments1

Value Name: your user name

Value Data:  the path to your docs folder ( ex. C:\Documents and Settings\your docs folder )

mydocuments2

Exit Registry editor and open my computer, your docs folder should now be visable

Written by Naveen P.N

October 3, 2009 at 1:57 am

About Metatag

leave a comment »

Metatags are for us to define our website to outside users.We can declare title,keywords etc.
There are two types of meta tags
(a)HTTP-EQUIV
(b)NAME
(a)HTTP-EQUIV
These tags are equivalent to http,Say for example if u click hyperlink which begins with http://
you are actually asking to transfer using http protocol.In additional what HTTP-EQUIV Metatags does is ,it
define additional information to be sent to the browser in the http header.This gives the web site creator additional;
control over his data.

(b)NAME
The NAME is acvtually used to define information which is to be referenced outside the document.Here is the actuall
data is passed to search engines.

Metatags must be placed b/w <Head> —–</HEAD> tags before the body
Note:
(a)On framed pages,be sure and include the metatags on the frameset page and the framed pages.
(b)An important note some people copy someones else’s Metatags and they have punished in the court(like trademarks etc.).

Attributes:
http-equiv=”name” content=”value”

Value Description and example

content -language Specifies the language.
content -script-type Defines scripting language used.
content -style-type Defines type of style sheets used.
content-type Specifies type of data within document.
expires Expiration date of the document.
ext-cache Define Netscape external cache.
imagetoolbar This turns off Internet Explorer’s image toolbar that appears when you hover over an image
page-enter Specifies the transition effect that is to be performed when the page is loaded.
page-exit Specifies the transition effect that is to be performed when the page is unloaded.
pics-label Includes rating information so content filters can do their job.
pragma Do not locally cache documents.
refresh Indicates the document displays for a specified amount of time before switching to a new URL.
set-cookie Sets the name and value for a persistent cookie.
site-enter Specifies the transition effect that is to be performed when the site is loaded.
site-exit Specifies the transition effect that is to be performed when the site is unloaded.
window-target Specifies the name of the frame for the current page.
name=”value”
Name and description of the element that is being set.

Value Description and example
abstract Define a secondary description.
author Records the name of the author of the document.
classification Classify the site into the appropriate category.
copyright Used to include copyright information in the document.
description Some search engines pick up this description to show with the results of searches.
distribution Declares whether a document is available to the web or on an intranet.
doc-class Indicates completion status of document.
doc-rights Indicates copyright status of document.
doc-type Specifies type of document.
expires Expiration date of the document.
generator The name of the program that created the document.
googlebot Define pages to be excluded from googebot indexing.
keywords Inform search engines what your web site or page is about.
MSSmartTagsPreventParsing Use this tag to prevent any Microsoft product from automatically generating smart tags.
owner Define the owner of the page or site.
progid
rating A simple rating for a site.
refresh Indicates the document displays for a specified amount of time before switching to a new URL.
reply-to Email address of contact for document.
resource-type Indicates the type of web resource.
revisit-after Defines how often search engine spiders should revisit your site.
robots Define pages to be excluded from robot indexing.

Written by Naveen P.N

October 2, 2009 at 12:28 pm

Posted in Web