.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

problem with using regex removing html tag attributes

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF

hi,all, I have the following code:

wstring myapp::PreProcessingTagStr(wstring wstrHtmlSrc)
	const wregex wregPattern(L"\\s*<([a-z][a-z0-9]*)[^>]*?(/?)>.*?</([a-z][a-z0-9]*)>\\s*");
	const wstring replacer = L"<$1$2>T";
	return regex_replace(wstrHtmlSrc, wregPattern, replacer);

void myapp::OnBnClickedTestButton5()
	// TODO: Add your control notification handler code here

	wstring wstrTxt = L"<SPAN class=scndInfo>(Hayes., UK, United Kingdom)</SPAN>";
	m_strVIPSResult += CString(L"") + PreProcessingTagStr(wstrTxt).c_str();

and it supposes to generate something like:


but the regex matches nothing, it just gives out the original string "

View Complete Post

More Related Resource Links

Embed Youtube inside Ajax Html Editor- problem



When inserting a simple embed of youtube inside the ajax editor, on firefox and chrome problems occur. On the other hand on internet explorer 8 everything works fine. I found this solution http://www.nopcommerce.com/boards/t/4228/bug-in-ajax-html-editor.aspx . 

My question is where do I find the DesignPanel.pre.js ?


Roderick Vella

problem when converting html to pdf using ItextSharp


 hi all

i have using itextsharp to convert html to pdf and its worked very good in english letters (A-Z) but when i trying to do it with arabic letters i have got empty pdf , can any one help me? what i should do ?

System.Net.Mail HTML Template Problem


What do I need here ?????? To make this work??

Dim MassMail As New MailMessage()

        Dim Template As ??????????????

        MassMail.To.Add(New MailAddress(TextBox_massemailto.Text))
        MassMail.From = New MailAddress("You@me.com")

        ' MassMail.CC.Add()
        MassMail.Subject = TextBox_massemailsubject.Text
        MassMail.Body = TextBox_massemailBody.Text
        ' MassMail.Body = Template.BodyFileName = "EmailTemplates/BusinessAdBrochure.htm"
        MassMail.Priority = MailPriority.High

        Dim smtpclient As New SmtpClient("relay-hosting.secureserver.net")
        smtpclient.Credentials = New System.Net.NetworkCredential(""You@me.com"", "pasword")
        smtpclient.Port = 25
        smtpclient.EnableSsl = False

Html.RenderPartial appears to be stripping Model of custom attributes



I have implemented a custom ModelMetadataProvider so that I can decorate my view models with some custom attributes and everything was working fine until I made use of a Partial View.

The following code in my view works fine: -

<%: Html.DisplayFor(x => x.Results) %>

Results is a List which renders a custom display template and is also decorated with a custom attribute.  Using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  If I look at the attributes collection parameter I can see that it does contain my custom attribute thus everything working as expected.

However, if I replace the above with the following line of code in my view then it breaks: -

<% Html.RenderPartial("ApplicationSearchResults", Model.Results, new ViewDataDictionary()); %>

All the Partial View contains is: -

<%: Html.DisplayFor(x => x) %>

Again using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  But this time if I look at the attributes collection parameter my custom attribute is not there.

Any idea

POST from html form viewstate problem

<p> Hi all, I have a website where people need to pay for a specific download (.pdf file). After they payed they get the download(A). My payment-provider can do a HTML-Postback to the site i want, for each succesfull payment. So the idea is that if someone payed, they do a postback to my server with a couple of parameters, so i can know that that specific email address has payed, and they get the download. I tested localy with a .html file on my desktop to postback a set of parameters to my local asp.net website. But in ONLY works if i include the __VIEWSTATE in my html file. And i cant get rid of the viewstate in my HTML of the aspx page. >test.html: <html><head></head><body> <h1>Dit is een test</h1> <form id="form1" action="http://localhost:25659/WebForm1.aspx" method="POST"> <input id="Button1" type="submit" value="submit!"/> 'IT ONLY WORKS IF I INCLUDE THE NEXT LINE: <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjA0OTM4MTAwNGRk" /> </form></body></html> Has anybody an idea to acomplish my goal? Maybe i can get some info about the postback in my global.asax? or create a HttpHandler for .html files? Anyone?   Thanks in advance, Vincent   </p>

Html editor word wrap problem

I created an html editor which uses an iframe for designing. The iframe doesnt wraps the text within it.... but the text keeps on extending in the same row towards the right. i tried setting scrolling='no' but it didnt work... tried word-wrap:break-word but thats also of no use........ please help! 

Problem: DataContract and DataMember attributes are not being recognized

I am having a strange problem. My service is otherwise working fine. However, now I want to add a custom object to be sent over to clients. I created a class to hold the data applied DataContract and DataMember attributes. However, compiler is not recognizing these attributes and giving me following error. The type or namespace name 'DataContractAttribute' could not be found (are you missing a using directive or an assembly reference?)  I could not figure our what assembly do I need to refer to. I am using VS2010 on WinXP. Thanks. kr

Regex pattern for text extraction within html tag

Hi guys, ive originally posted this question in the "visual basic general" category and was forwarded here.   I am looking for the regex pattern for text extraction within this html tag  <span class="listingTitle">Inner Balance</span> This is the full link if its needed: http://www.yellowpages.ca/search/si/1/Estheticians/Calgary+AB Get I get some assistance please.

urlrewritingnet problem with html

Hi All, I have set up url rewriting in my web.config with regex rules and it works correct for all html files. Problem: When I have a html file that is not a rule, there is an error. How can I keep using not rewrited html files?   So.. I only want to rewrite if the file does not exist. < urlrewritingnet rewriteOnlyVirtualUrls="true" does not seem to work Thanks  

Removing the HTML wrapped around web parts?

I work with both SP 2007 and 2010 for WCM and this has always been a problem. Every web part or web part zone is almost always wrapped in at least one table and/or several divs. In 2010 I'm finding that even the XLV part is getting this wrapper. Besides being a lot of bloat that wastes bandwidth, it makes it much harder to customize the look and feel of the site. Is there a way to turn this off or modify the output? I don't care what it has to do for edit mode to make the UI function, but when serving pages to anonymous web surfers I'd like to eliminate the code. As an example, here's the beginning wrapper code for a CQWP in SP 2010. The actual content that needs to be displayed is a simple unordered list: <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td id="MSOZoneCell_WebPartWPQ1" valign="top" class="s4-wpcell-plain"> <table class="s4-wpTopTable" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top"> <div WebPartID="c0f138b4-3002-4e47-a797-e4cd1a2b23c1" HasPers="false" id="WebPartWPQ1" width="100%" class="ms-WPBody noindex" allowDelete="false" style="&qu

Regex: Get inner html of div

Hi all, I have been trying for a long time to create regEx function that would retrieve inner html of div but still no luck. What I want to do is to retrieve inner html of div with specific class.e.g.Suppose the input is<body>.....<div class="Product"><div class="id">1</div><span>xyz - 1090<br>New Product</span><div><div class="Product"><div>2</div><div><div class="Product"><div>1</div><br><p>322</p><div>...</body>As you can see inner html itself can contain div tag and have no fixed structure (though will have correct html structure - opening and closing tag). So, how to get the inner html of div with class "Product".Thanks in advance.

Problem with Regex (BBCode)


I have written code which enables BBCode functionality on my site:

Imports System.Collections.Generic
Imports System.Text.RegularExpressions
Imports CodeKicker.BBCode

Namespace GPE.Classes.UI

    ''' <summary>
    ''' BBCode Helper allows formatting of text
    ''' without the need to use html
    ''' </summary>
    Public Class GPEBBCode
        ' regular regex...
        Private Shared m_options As RegexOptions = RegexOptions.IgnoreCase Or RegexOptions.Multiline Or RegexOptions.Singleline Or RegexOptions.Compiled

        Private Shared ReadOnly _rgxBold As String = "\[B\](?<inner>(.*?))\[/B\]"
        Private Shared _rplBold As String = "<b>${inner}</b>"

        Private Shared ReadOnly _rgxItalic As String = "\[I\](?<inner>(.*?))\[/I\]"
        Private Shared _rplItalic As String = "<i>${inner}</i>"

        Private Shared ReadOnly _rgxBr As String = "[" & vbCr & "]?" & vbLf
        Private Shared _rplBr As String = "<br/>"
        Private Shared ReadOnly _rgxBullet As String = "\[\*\]"

        Private Shared ReadOnly _rgxCenter As String = "\[center\](?<inner>(.*?))\[/center\]"
        Private Shar

Removing HTML head code

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">


<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
 /* Font Definitions */
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
	panose-1:2 15 5 2 2 2 4 3 2 4;}
	panose-1:2 11 6 4 3 5 4 4 2 4;}

MVC 3.0 preview 1, Html.RenderAction Problem


Hi all,

I'm trying to use Html.RenderAction with MVC 3.0 preview 1 and i'm getting an error. i have the following controller:

	public class HelpController : Controller
public ActionResult Detail(int id)
ViewModel.Title = "Help Title! " + id.ToString();
ViewModel.Content = "Help Content!" + id.ToString();

return View();

and in another controller, i'm trying to do:

@Html.RenderAction("Detail", "Help", new { id = 3 });

but i keep getting:
CS1502: The best overloaded method match for 'Microsoft.WebPages.WebPageUltimateBase.Write(Microso

How to minify html , css , javascript ( removing white spaces etc )


i am looking for a tool which will minify my code when publishing website


or it may be run time minify too if not using too much cpu power



Problem displaying a view correctly in MVC app using HTML.TextBoxFor() with VB



I have a test app with a form view.

I cannot get the view to display correctly instead of displaying a series to text boxes it displays quoted html.

I suspect that my problem is related to my VB syntax for my Linq

The C# equivilant works but my shop uses VB so I must convert the code.

Here is the code from the view:

      <% Using (Html.BeginForm)%>
          <p>Your name: <%: Html.TextBoxFor(Function(m) m.Name).ToString%></p>
          <p>Your email: <%: Html.TextBoxFor(Function(m) m.Email).ToString%></p>
          <p>Your phone: <%: Html.TextBoxFor(Function(m) m.Phone).ToString%></p>
          <p>Will you attend? <br />
          <%  Dim slist As New Generic.List(Of SelectListItem)
          slist.Add(New SelectListItem With {.Text = "Yes", .Value = Boolean.TrueString})
          slist.Add(New SelectListItem With {.Text = "No", .Value = Boolean.FalseString})
       <%: Html.DropDownListFor(Function(m) m.WillAttend, slist, "Choose an option")%>
       <input type="submit" value="Submit RSVP" />
       <% End Using%>

Problem Removing Site Breadcrumb


Hi guys,

ive recently taken over the job of maintaining the company website and have been asked to remove the breadcrumb on our sharepoint site...

so i located the master page and found the breadcrumb within that page.



             <div id="layoutBreadcrumb">
                <!--- --- ---  Breadcrumbs --- --- --->
                <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
                    <asp:SiteMapPath EnableTheming="false" ID="siteMapPath" Runat="server" SiteMapProvider="CurrentNavSiteMapProviderNoEncode"
                        RenderCurrentNodeAsLink="false" PathSeparator=" &gt; " CurrentNodeStyle-CssClass="breadcrumbCurrent" NodeStyle-CssClass="ms-sitemapdirectional"/>

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend