Default.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="StringOperation.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter the String :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Result" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Reset" />
</p>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<p>
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
</p>
<asp:Label ID="Label3" runat="server" Text=""></asp:Label>
<p>
<asp:Label ID="Label4" runat="server" Text=""></asp:Label>
</p>
<asp:Label ID="Label5" runat="server" Text=""></asp:Label>
<p>
<asp:Label ID="Label6" runat="server" Text=""></asp:Label>
</p>
<asp:Label ID="Label7" runat="server" Text=""></asp:Label>
<p>
<asp:Label ID="Label8" runat="server" Text=""></asp:Label>
</p>
<asp:Label ID="Label9" runat="server" Text=""></asp:Label>
<p>
<asp:Label ID="Label10" runat="server" Text=""></asp:Label>
</p>
</form>
</body>
</html>
Default.aspx.cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace StringOperation
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
String s = TextBox1.Text;
Label1.Text = "String Length :" + s.Length;
Label2.Text = "Substring :" + s.Substring(4,3);
Label3.Text = "Upper String :" + s.ToUpper();
Label4.Text = "Lower String :" + s.ToLower();
String rev = "";
for (int i = s.Length - 1; i >= 0; i--)
{
rev = rev + s[i];
}
Label5.Text = "Reverse String :" + rev.ToString();
Label6.Text = "Replace 's' by 't' in string :" + s.Replace('s','t');
Label7.Text = "Insert 'u' in String :" + s.Insert(3,"u");
Label8.Text = "String trancate:" + s.Trim();
Label9.Text = "Remove Length :" + s.Remove(4);
Label10.Text = "Index of Stirng :" + s.IndexOf('e');
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "";
Label4.Text = "";
Label5.Text = "";
Label6.Text = "";
Label7.Text = "";
Label8.Text = "";
Label9.Text = "";
Label10.Text = "";
}
}
}
0 Comments