Now you have to create a web site.
- Go to Visual Studio 2010
- New-> Select a website application
- Click OK
Now add a new page to the website.
- Go to the Solution Explorer
- Right-click on the Project name
- Select add new item
- Add new web page and give it a name
- Click OK
Now drag and drop two Button and two Label controls onto the form. One is used to show the message with single quotes. The second one is used to show the message with double quote. Let's take a look at a practical example.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="DisplaySinglequetes" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="DisplayDoublequetes" />
</div>
</form>
</body>
</html>
Print a string with single Quotation mark
Now double-click on the first Button control and write the following code to show the message with single quotes. For example we take a string variable named strSingleQuote which contains a message.
protected void Button1_Click(object sender, EventArgs e)
{
string strSingleQuote = "'Hello Rohatash Kumar'";
Label1.Text = strSingleQuote;
}
Print a string with double Quotation mark
Now double-click on the second Button control and write the following code to show the message with double quotes. For example we take a string variable named strDoubleQuote which contains a message.
protected void Button2_Click(object sender, EventArgs e)
{
string strDoubleQuote = "Hi ''I am fine'' Rohatash";
Label2.Text = strDoubleQuote;
}
In code-behind write the following code.
Code-behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string strSingleQuote = "'Hello Rohatash Kumar'";
Label1.Text = strSingleQuote;
}
protected void Button2_Click(object sender, EventArgs e)
{
string strDoubleQuote = "Hi ''I am fine'' Rohatash";
Label2.Text = strDoubleQuote;
}
}
Now run the application and test it.
Now click on the Button DisplaySinleQuotes to show the message with single quotes.
Now click on the Button DisplayDoubleQuotes to show the message with double quotes.