How do I explode/implode a string in asp.net

So you want to separate your string using explode or join your string using implode in vb.net? Explode/implode are functions of the php environment and do not exist in asp.net therefore you must use the split() function to get your results for explode and join() for implode.

Split() Example

mystring = “hello;sir;how are you”;

arrayData=mystring.Split(mystring,”;”)
Result
arrayData(0) would equal “hello”
arrayData(1) would equal “sir”
arrayDate(2) would equal “how are you”

Join() Example

Dim JoinArray(3)

JoinArray(0) = "Welcome" JoinArray(1) = "to" JoinArray(2) = "Web Infinite"

Dim strSentence as String strSentence = join(JoinArray)

Result strSentence would equal to “Welcome to Web Infinite”

... Read More

ASP.Net – Rewrite URL in VB.Net

Application_BeginRequest method of Global.asax file can be used to rewrite the URL of the current page.? Following code snippet shows you how to achieve this goal.

<%@ Application Language=?VB? %> <script runat=?server?>

Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

?This is for dynamic redirection without having to create a directory in the root folder. We ?needed to change the 404 in IIS under custom errors to /(forward slash) instead of the default 404b.html

If Regex.IsMatch(Request.Url.AbsoluteUri, ?404;?) ?Get the url from browser address bar Dim UrlSplit(), url as String UrlSplit = Request.Url.AbsoluteUri.Split(??404;?) ?Split the url where the error occured in this case 404 url = replace(UrlSplit(1), ?404;?, ??) url = replace(url, ?http://www.youraddress.com?, ??) ?Replaces the youraddress.com address and puts nothing

?Select Case to check where the page should be redirect too. Select Case url Case ?/aboutmypage? response.Redirect(?/aboutus?) ? Redirects to correct url. Case ?/yourprogram? response.Redirect(?/programs/yourprogram?) Case ?/canucks? response.Redirect(?/sports/hockey/canucks?) Case Else response.redirect(?/help/sitemap/index.aspx?) End Select End If End Sub

</script>

... Read More