ASP.NET - how to replace html tags from label control

Asked By Anto Bilson
10-Feb-12 02:23 AM

 hi ..

I've bind some content from DB to Label Control..The content is get it from Edit so some extra html tags are embedd with content..now i bind the content the extra tags also display in label control ..how to solve the issue i tried htlmdecode and encode but not solved

disply in label

<p>&lt;p&gt;&lt;strong&gt;Descriptiokkkkkn&lt;/strong&gt;&lt;/p&gt;</p>

pls suggest to solve the issue

thanks
  Somesh Yadav replied to Anto Bilson
10-Feb-12 03:33 AM
f you want to remove the html tags from that field and display in label first you need to pass
that html to text parser like this

public string ConvertHtmlToText(string html)
    {    
   return   System.Text.RegularExpressions.Regex.Replace(html,@"<[^>]*>","").Trim();     
    } Above functinon will remmove all html tag and return simple text
  dipa ahuja replied to Anto Bilson
10-Feb-12 04:09 AM
 protected void Button1_Click(object sender, EventArgs e)
  {
    string s = "Hello<br>World!";
    Literal1.Text = Server.HtmlEncode(s);
 
    string[] data = TextBox1.Text.Split(' ');
    string firstname = data[0].ToString();
    string lastname = data[1].ToString();
 
    Response.Write("Firstname: " + firstname + "</br> LAstname" + lastname);
  }
 
Create New Account
help
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are the various modes of storing ASP.NET session
is used In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source. In ADO you cant update the database from the recordset. ADO.NET the data adapter allows you to control how the changes to the dataset are transmitted to the database. On order to get in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level debugging trace value in web.config file Enable trace enabled = true. If there is a calendar control to be included in each page of your application, and and we do not intend
Migration from ASP to ASP.net How to convert ASP site to ASP.NET site using C# http: / / www.asp.net / downloads / archived-v11 / migration-assistants / asp-to-aspnet hi, ASP.NET framework is very much different from unstrucured ASP and there is no correct way to
trunk / ExchangeCurrencyRate.Parser / Program.cs?spec = svn6&r = 6 Introduction this article " Currency Converter with ASP.NET Web Forms ", explained how to load XML data with ASP.NET from the"Rates.xml" file. In this article I have created Currency ConverterServer which can 152.844< / TD> <TD align = right> 166.386< / TD> <TD align = right> 251.917< / TD> * / Regex regex = new Regex(@"<td.*?> (.+)< / td> +", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); MatchCollection matches = regex.Matches(rawHtml); if (matches.Count > 0) { / / Get the first match foreach(Match match in matches
shows the error provider, but when click the submit button the "invaild emailid" store in db i want coding for validate that form?????????????? Try it on below way and let me know If txtEmail_1.Text <> "" Then Dim rex As Match = Regex.Match(Trim(txtEmail_1.Text), " ^([0-9a-zA-Z]([-. \ w]*[0-9a-zA-Z])*@([0-9a Use this code- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e_ As System.EventArgs) Handles Button1.Click If TextBox1.Text = "" Then ErrorProvider1.SetError(TextBox1, "Cannot leave textbox blank") Else 1, 3} \ .) | (([a-zA-Z0-9 \ -]+ \ " + @ ".)+))([a-zA-Z]{2, 4} | [0-9]{1, 3})( \ ]?)$" ; Regex re = new Regex(strRegex); if (re.IsMatch(inputEmail)) return ( true ); else return ( false ); } Use the System.Text.RegularExpressions.Regex class: Function IsEmail(Byval email as string) as boolean Static emailExpression As New Regex( "^[_a-z0-9-]+(.[a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2 Continue" Display = "None" CssClass = "data-row"> < / asp:RegularExpressionValidator> You can do it with the errorProvider control: 1. Add an Error provider control 2. Implement the Textbox's Validating event private void