Retrieve First Name and Last Name from string in asp.net

Retrieve First Name and Last Name from string in asp.net

VB.Net:

Dim name As String = “Joseph Van Andrews”

‘ Split string based on spaces
Dim names As String() = name.Split(New Char() {” “c})

‘ Seperate the first name from the rest of the string
Dim lastName as string = name.substring(names(0).length())

Dim nameString as string = “the First Name is: ” + names(0) + ” and the Last Name is: ” + lastName

response.write(nameString)

C#.Net:

string name = “ABC DEF XYZ”;

// Split string based on spaces
string[] names = name.Split(new char[] { ‘ ‘ });

// Seperate the first name from the rest of the string
string lastName = name.Substring(names[0].Length());

string nameString = “the First Name is: ” + names[0] + ” and the Last Name is: ” + lastName;

response.write(nameString);

Happy Coding 🙂

Advertisements

Jquery Redirect to Another Page After few seconds or Some Time Delay in Asp.net

Introduction:

Here I will explain how to redirect to another page after 5 seconds or some time delay in jQuery.

Description
   
In previous articles I explained calculate age with years months and days using jqueryexpanding collapsing sliding div jquery and many articles relating to JQuery and JavaScript. Now I will explain how to redirect to another page after 5 seconds or some time delay injQuery.

To implement this functionality we need to write the following code:
 

<head runat=”server”>

<title>JavaScript redirect to another page after 3 seconds or Sometime</title>
<script type=”text/javascript”
src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js“>
</script>
<script type=”text/javascript”>
var i = 0;
$(document).ready(function () {
ShowRedirectTime();
})
function ShowRedirectTime() {
var dt = new Date();
var redirecturl = ‘http://www.nipulparikh.com‘;

document.getElementById(“lblRemaingTime”).innerHTML = 3 – i + ”
Seconds”;
i++;
if (i == 3) {
setTimeout(“location.href=redirecturl”, 0);
}
window.setTimeout(“ShowRedirectTime()”, 1000);
}
</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div style=”text-align: center;”>
This Page will Redirect to Another Page within:
<label id=”lblRemaingTime” style=”font-weight: bold; font-size: 12pt”>
</label>
</div>
</form>
</body>
</html>

 

Happy Coding..!!! 🙂