Showing posts with label point. Show all posts
Showing posts with label point. Show all posts

Saturday, March 24, 2012

stripping out html tags for plain txt email

I was wondering what the best way to strip the html tags off of a page and add vbclf and such for plain text emailing of web pages

if you could point me in the right direction it would be greatTo remove HTML tags from awell-formed document:
Converting HTML to Text
awesome what a life saver
now how could I change the code below so that it replaces the </p> and <br> with a _vbclrf or a plaintext line break and also how can I get it to remove all of the dead space I see a comment posted on the page you linked about doing it but no one actually does


Public Function StripTags(ByVal HTML As String) As String
' Removes tags from passed HTML
Dim objRegEx As _
System.Text.RegularExpressions.Regex
Return objRegEx.Replace(HTML, "<[^>]*>", "")
End Function

Try the following:
 Import System.Text.RegularExpressions

Public Function StripTags(ByVal HTML As String) As String
Dim cleanString As String = HTML
Dim objRegEx As Regex

' First, remove whitespace
objRegEx = New RegEx( "\s{2,}" )
cleanString = objRegEx.Replace( cleanString, " " )

' Second, replace HTML linebreaks with text line breaks
objRegEx = New RegEx( "((</p>)|(<br ?/?>))" )
cleanString = objRegEx.Replace( cleanString, System.Environment.NewLine )

' Third, clean up any occurrence of newline + space
objRegEx = New RegEx( "(^|\n) +" )
cleanString = objRegEx.Replace( cleanString, String.Empty)

' Finally, remove HTML tags
objRegEx = New RegEx( "<[^>]*?>" )
cleanString = objRegEx.Replace( cleanString, String.Empty)

Return cleanString
End Function

Tuesday, March 13, 2012

Stuck on loading pages into a placeholder

Hi Folks,

Can someone point me to a sample or tutorial or the code to load pages into a placeholder.

I have a menu bar on the left of the page and am trying to load the clicked pages on the right.

Any ideas,

Cheers
NickWelcome to the ASP.NET forums, Nick.

You may be very interested inUser Controls. (They were originally called Pagelets, since they are very much like you described ... littles pages that you embed within your main page.)

That link is one of theQuickStart Tutorials which you might want to look through.

Hope this helps.
Hmm ive had a read over and im still stuck.

do i include the code in a script block or in the codebehind file??
Umm, neither.

Can you show the code for your page, indicating which part you want to separate out as the menu bar, and which page will have the content loaded into it?

If you do so, can you please post it between<code> and</code> tags?
Here it is.


for the link
<TD>
<a id="goHome" runat="server"><img src="http://pics.10026.com/?src=images/myWebHome.jpg"></a>
</TD>
with goHome.HRef defined in the cs file.

<TABLE cellSpacing="10" cellPadding="0" width="100%" border="0">
<asp:placeholder id="PageBody" runat="server"></asp:placeholder>
</TABLE>

I'm trying to get the link to display in the placeholder.
Cheers,
Nick
Why not use frames?
One more question before I can show you an answer.

When you say you are trying to load "pages" into a Placeholder, do you mean anentire webpage inside the table cell? Or do you just want to load differentcontent into the table cell, based on the button the user has clicked?
At the moment it is content contained within an aspx file, so an entire page I guess, what other options are available. I'm a bit of a noob to all this and have to get myself on a steep learning curve. Thanks for all your help and time.
You should really be putting yoursections of content in a User Control (.ascx), Loading them (using Page.LoadControl) when appropriate and then adding them to the PlaceHolder Control. For example:

 void Page_Load ( Object src, EventArgs eArgs ) {

Control page;

switch ( QueryString [ "page" ] ) {

case "Home" : page = LoadControl ( "/controls/home.ascx" );
break;
case "About" : page = LoadControl ( "/controls/about.ascx" );
break;
...
}

PageBody.Controls.Add ( page );
}


I assume this goes into a <script> block in the actual page. Now how do I pass the param to the switch?
Either in a <script> declaration block or CodeBehind.

The requesting URL would look like:

 http://www.domain.com/default.aspx?page=Home