String Function Using Javascript and C# in Asp.Net

String Function Using Javascript and C#

String Function uppercase,index,substring Using Javascript and C# in Asp.Net.


Html Coding

<html xmlns="">
<head runat="server">
    <script type="text/javascript">

        //String Concatination

        function concat()
                var Str1 = "Dot";
                var Str2 = "Net";
                var c = Str1.concat(Str2.toString());
        //String IndexOf

        function indexof()
            var str1 = "Welcome to Dotnet Drizzles";


        //String  UpperCase
        function Ucase()
           var Str1 = "Dotnet Drizzzles";


        // String Last indexof
        function LastIndexof()
           var str1 = "Welcome To Dotnet  Drizzles and Asp Dotnet";

        // String Substrings
        function Substring()
            var str1 = "DRIZZLES";


        // String Replace

        function replac()
            var str1 = "Dotnet";
            alert(str1.replace("Dotnet", "DotnetDrizzles"));

    <form runat="server">
<div align="center">
        <tr><td><input type="button" value="Concat"  onclick="concat();" /></td><td><asp:Button ID="Button1" runat="server" Text="Concat" OnClick="Button1_Click1" /></td></tr>
        <tr><td>         <input type="button" value="IndexOf" onclick="indexof();" />
</td><td>        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="IndexOf" />
        <tr><td>        <input type="button" value="LastIndexOf" onclick="LastIndexof();" />
</td><td>        <asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="LastIndexOf" />
        <tr><td>          <input type="button" value="Uppercase" onclick="    Ucase();" />
</td><td>        <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Uppercase" />
        <tr><td>         <input type="button" value="Substring" onclick="Substring();" />
</td><td>        <asp:Button ID="Button5" runat="server" OnClick="Button5_Click" Text="Substring" />
        <tr><td>  <input type="button" value="Replace" onclick="replac();" />     
</td><td><asp:Button ID="Button6" runat="server" OnClick="Button6_Click" Text="Replace" /></td></tr>
        <tr><td colspan="2"><asp:Label ID="Label1" ForeColor="Red" runat="server" Text="Label"></asp:Label></td></tr>

                     C# Coding

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class StringFunctions : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void Button1_Click1(object sender, EventArgs e)
        string  Str1 = "DotNet ";
        string  Str2 = "Drizzles";
        Label1.Text = Str1 + Str2;
    protected void Button2_Click(object sender, EventArgs e)
        string Str1 = "Welcome to Dotnet Drizzles";
        Label1.Text = Str1.IndexOf("Dotnet").ToString();       
    protected void Button3_Click(object sender, EventArgs e)
        string Str1 = "Dotnet Drizzzles";
        Label1.Text = Str1.ToUpper();
    protected void Button4_Click(object sender, EventArgs e)
        //LastIndexOf Dotnet in str1

        string str1 = "Welcome To Dotnet  Drizzles and Asp Dotnet";
        Label1.Text = str1.LastIndexOf("Dotnet").ToString();

    protected void Button5_Click(object sender, EventArgs e)
        string str1 = "DRIZZLES";
        Label1.Text = str1.Substring(2,3).ToString();
    protected void Button6_Click(object sender, EventArgs e)
        string str1 = "Dotnet";
        Label1.Text = str1.Replace("Dotnet", "DotnetDrizzles");


First Create New Webform - Add Buttons & Label for Required - Add String Function in Javascript Script - Next Call Related Function

Next -  Button click Event - Add String function Using C#


Post a Comment