Solved

ASP.NET/VB: Trim quotation marks from beginning and end

Posted on 2011-09-06
7
485 Views
Last Modified: 2012-05-12
Using ASP.NET/VB, I would like to trim quotation marks from the beginning and end.

These charactors should be REMOVED if they are the first or last character of the Headline.

"“”
<h2><%#Container.DataItem("Headline")%></h2>

Open in new window

0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 500 total points
ID: 36490709
code infront:

 <h2><% FormatTitle(Container.DataItem("Headline"))%></h2>

code behind:

protected function FormatTitle(title As Object) As String
    Dim temp as String
    Dim originalString As String = title.ToString()

    if originalString.StartsWith(""") then
        temp = originalString.SubString(1)
    else
        temp = originalString
    end if

     if temp.EndsWith(""") then
         temp = temp.SubString(0, temp.Length - 1)
    end if

   return temp

end fuction
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36490942
0
 
LVL 16

Author Comment

by:hankknight
ID: 36490980
Thanks.  disrupt, this needs to be VB not C#.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 16

Expert Comment

by:disrupt
ID: 36490981
"TrimStart and TrimEnd are supposed to take a character array as a parameter. If you type the keyword null instead, it will trim the white space (blank characters)."

you can also just do this:

returnValue.TrimStart( '" ', '“','”' );
returnValue.TrimEnd( '" ', '“','”' );
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36490993
It will work in vb .net fine just leave out the semicolon at the end :)
0
 
LVL 16

Author Comment

by:hankknight
ID: 36491145
Thanks, disrupt.   I awarded the points just moments before you made your post.

strickdd, you solution works.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question