Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Use Split Function in JQuery to Split the String in Asp.net

Sep 1, 2012
Introduction

Here I will explain how to split the string using split function in JQuery with asp.net.

Description:
  
In previous posts I explained many articles relating to JQuery. Now I will explain how to split the string using split function in JQuery.

To split the string we have function called Split() in JQuery by using that we can split string based on our specific character that would like as shown below


<script type="text/javascript">
$(document).ready(function() {
$('#btnSplit').click(function() {
var name = $('#txtName').val();
var arr = name.split('@');
var sampletxt = '';
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
}
})
});
</script>
If you observe above script I used special character '@' to split string. If you want check this code in sample check below code

Example:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Split the string using Split function in JQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#btnSplit').click(function() {
var name = $('#txtName').val();
var arr = name.split('@');
var sampletxt = '';
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
}
})
});
</script>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr><td align="right"><b>Enter Text:</b></td>
<td><asp:TextBox ID="txtName" runat="server" Text="Aspdotnet@Suresh@Dasari"/></td>
</tr>
<tr><td align="right"></td>
<td><asp:Button ID="btnSplit" runat="server" Text="Split Text" /></td>
</tr>
</table>
</form>
</body>
</html>
Demo

To check demo click on button

Enter Text:

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

9 comments :

Anonymous said...

nice

smspostbox said...

thanks....,

Anonymous said...

awesome...

Anonymous said...

I am using Visual Web Developer 2008 on Windows XP. I downloaded the toolkit from asp.net website. I created a new tab called Ajax Control Toolkit in the toolbox and added the extenders in that tab. Everything works fine and dandy. But when I close Visual Web Developer and reopen it, the control toolkit is gone and I have to add it again. How can I add it permanently or am I doing something wrong?

Suresh Dasari said...

@Comment 4..
Check this article
http://www.aspdotnet-suresh.com/2011/11/how-to-install-ajax-control-toolkit-in.html

Santhosha said...
This comment has been removed by the author.
Unknown said...

Hello sir thanks for your reply, i did the same whatever u have in your article but when i close the Visual Studio and open it again the TOOLBOX does not shows AJAX controls which we have added, i want to retain it permanently when i open the IDE every-time.

Your articles are really very nice anyone can be easily understand, could you please write an article about how to use Facade, design patterns Factory methods abstract class in 3 tier architecture. Please sir.

Unknown said...

how to relationship parent to child in data table in c# asp.net

Aspen Haley said...

Thank you for giving this topic with good example so that i can understand easily and I will use in my project also.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.