How to Split string Between Characters from label Using C#

Split string Between Characters from label

Split String   two or more Character from label or Variables Using Asp.Net C#.



                            HTML Coding

<html xmlns="" >
     <title>How to Split string Between Some characters in label Using C#</title>  



    <form runat="server">
        <div align="center">
        <br />
<asp:Label ID="lblSplit" runat="server" Text="(DotnetdrizzleS)"></asp:Label>
        <br />
<asp:Label ID="lblResult" runat="server" ForeColor="Red"></asp:Label>
        <br />
<br />
<asp:Button ID="Button1" runat="server" Text="Split" OnClick="Button1_Click" /></div>


                                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 Default4 : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    protected void Button1_Click(object sender, EventArgs e)
        // (DotnetdrizzleS)
        lblResult.Text = lblSplit.Text.Split('(', ')')[1];  // 1 is destination character of split (index based)



Add New Webform - Select Label & Button from 

ToolBox - Text add to label

Next - Code Behind file - add - split for label string with index assign


Post a Comment