.net - replace function - issue

Discussion in 'C#' started by intothemiddle, Dec 14, 2006.

  1. #1
    Hi All,

    I'm aiming to do a replace function in .net and it doesn't seem to be working..
    What I have so far is, but it doesnt seem to be working..

    <script runat="server">
    Sub Page_Load
    lblDescription.Text = Replace(lblDescription.Text,"new","original")
    End Sub
    </script>
    <asp:Label ID="lblDescription" runat="server">
    </asp:Label>

    Anyone able to help me? :)
     
    intothemiddle, Dec 14, 2006 IP
  2. shaileshk

    shaileshk Well-Known Member

    Messages:
    455
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    
    Sub Page_Load
    lblDescription.Text = Replace(lblDescription.Text,"new","original")
    
    strDesc=lblDescription.Text 
    strDesc=Replace(strDesc,"new","original")
    lblDescription.Text=strDesc
    End Sub
    
    Code (markup):
    you can try using string varible
    i am not sure bcz i am C# programmer
     
    shaileshk, Dec 14, 2006 IP
  3. CSPlayer

    CSPlayer Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What you want is

    lblDescription.Text = lblDescription.Text.Replace("new","original")
    Code (markup):
     
    CSPlayer, Dec 14, 2006 IP