Showing posts with label client. Show all posts
Showing posts with label client. Show all posts

Saturday, March 24, 2012

stripping tags from source on render

Hi,
What way could I strip certain tags (like HTML comments) from the HTML being
delivered to the client? I don't mean what regexp to use, but where do I
put this stripping code? I'm thinking something in the Global.asax, but I
can't find any reference to it having a Render or PreRender event or how to
tie into them if I did! I'd ideally like some help along the lines of:

1 - Where to put the code
2 - example of how to alter the source being delivered to the client

Thanks,
LanceHi Lance:

You could use a Response.Filter, like the one in this article:
http://www.codeproject.com/aspnet/R...pacesAspNet.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 17 Jun 2005 11:43:50 +0100, "Lance"
<lance@.[nospam]keayweb.com> wrote:

>Hi,
>What way could I strip certain tags (like HTML comments) from the HTML being
>delivered to the client? I don't mean what regexp to use, but where do I
>put this stripping code? I'm thinking something in the Global.asax, but I
>can't find any reference to it having a Render or PreRender event or how to
>tie into them if I did! I'd ideally like some help along the lines of:
>1 - Where to put the code
>2 - example of how to alter the source being delivered to the client
>Thanks,
>Lance
Hi Lance,

I'd look at the Page.Render event. This takes an HtmlTextWriter parameter
where you can modify the contents before calling the base.Render method.

HTH
--
Ian Lane

"Lance" wrote:

> Hi,
> What way could I strip certain tags (like HTML comments) from the HTML being
> delivered to the client? I don't mean what regexp to use, but where do I
> put this stripping code? I'm thinking something in the Global.asax, but I
> can't find any reference to it having a Render or PreRender event or how to
> tie into them if I did! I'd ideally like some help along the lines of:
> 1 - Where to put the code
> 2 - example of how to alter the source being delivered to the client
> Thanks,
> Lance
>
Thanks! I thought i had seen it somewhere on good 'ol codeproject!

"Scott Allen" <scott@.nospam.odetocode.com> wrote in message
news:k3s5b1drg28qbudj23ggjs1l8r861cuqhh@.4ax.com...
> Hi Lance:
> You could use a Response.Filter, like the one in this article:
> http://www.codeproject.com/aspnet/R...pacesAspNet.asp
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Fri, 17 Jun 2005 11:43:50 +0100, "Lance"
> <lance@.[nospam]keayweb.com> wrote:
> >Hi,
> >What way could I strip certain tags (like HTML comments) from the HTML
being
> >delivered to the client? I don't mean what regexp to use, but where do I
> >put this stripping code? I'm thinking something in the Global.asax, but
I
> >can't find any reference to it having a Render or PreRender event or how
to
> >tie into them if I did! I'd ideally like some help along the lines of:
> >1 - Where to put the code
> >2 - example of how to alter the source being delivered to the client
> >Thanks,
> >Lance
I'd have to call the code from every page using this method, right? If I
could call it from one location (global.asax) that would be great!

"Ian Lane .enizin.net>" <ian@.<nospam> wrote in message
news:329AC863-65C0-41DC-B99E-2C47F83EA16F@.microsoft.com...
> Hi Lance,
> I'd look at the Page.Render event. This takes an HtmlTextWriter parameter
> where you can modify the contents before calling the base.Render method.
> HTH
> --
> Ian Lane
>
> "Lance" wrote:
> > Hi,
> > What way could I strip certain tags (like HTML comments) from the HTML
being
> > delivered to the client? I don't mean what regexp to use, but where do
I
> > put this stripping code? I'm thinking something in the Global.asax, but
I
> > can't find any reference to it having a Render or PreRender event or how
to
> > tie into them if I did! I'd ideally like some help along the lines of:
> > 1 - Where to put the code
> > 2 - example of how to alter the source being delivered to the client
> > Thanks,
> > Lance

Stripping out unwanted characters

How can I strip out unwanted characters in a string before updating the
database? For instance, in names & addresses in our client table, we want
only letters and numbers, no punctuation. Is there a way to do this?HI,

Use regular expression to remove unwanted characters and then send the
string to database. Here is a sample code to remove non-alphanumerical
characters from a string.

hoep this will help you...

public static void Main()

{

/*Reg expression to find non-alphanumeric characters*/

string pattern = @."[^A-Za-z0-9]";

/*include System.Text.RegularExpressions name space*/

Regex rgx = new Regex(pattern);

string inputStr = "ab$!Cd&%$gf!";

/*Replace non-alphanumeric characters with space*/

string outputStr = rgx.Replace(inputStr, " ");

Console.WriteLine("Output string:"+ outputStr);

}

Cheers
Vinu

"et" <eagletender2001@.yahoo.com> wrote in message
news:ODVkXK7NGHA.668@.TK2MSFTNGP11.phx.gbl...
> How can I strip out unwanted characters in a string before updating the
> database? For instance, in names & addresses in our client table, we want
> only letters and numbers, no punctuation. Is there a way to do this?
Function StripUnwantedChars(ByVal StringToStrip AsString) AsString
Dim stripped AsString
If StringToStrip <> "" Then
stripped = Regex.Replace(StringToStrip, "<(.|\n)+?>", String.Empty)
Return stripped
Else
Return ""
EndIf
EndFunction

Note : insert all the characters you want to strip inside the quotes.

For example, instead of :
stripped = Regex.Replace(StringToStrip, "<(.|\n)+?>", String.Empty)

use :
stripped = Regex.Replace(StringToStrip, "<!#(.|\n)+?>", String.Empty)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"et" <eagletender2001@.yahoo.com> wrote in message news:ODVkXK7NGHA.668@.TK2MSFTNGP11.phx.gbl...
> How can I strip out unwanted characters in a string before updating the database? For instance,
> in names & addresses in our client table, we want only letters and numbers, no punctuation. Is
> there a way to do this?
Thanks, everyone, that's exactly what I was looking for.

"et" <eagletender2001@.yahoo.com> wrote in message
news:ODVkXK7NGHA.668@.TK2MSFTNGP11.phx.gbl...
> How can I strip out unwanted characters in a string before updating the
> database? For instance, in names & addresses in our client table, we want
> only letters and numbers, no punctuation. Is there a way to do this?

Stripping out unwanted characters

How can I strip out unwanted characters in a string before updating the
database? For instance, in names & addresses in our client table, we want
only letters and numbers, no punctuation. Is there a way to do this?HI,
Use regular expression to remove unwanted characters and then send the
string to database. Here is a sample code to remove non-alphanumerical
characters from a string.
hoep this will help you...
public static void Main()
{
/*Reg expression to find non-alphanumeric characters*/
string pattern = @."[^A-Za-z0-9]";
/*include System.Text.RegularExpressions name space*/
Regex rgx = new Regex(pattern);
string inputStr = "ab$!Cd&%$gf!";
/*Replace non-alphanumeric characters with space*/
string outputStr = rgx.Replace(inputStr, " ");
Console.WriteLine("Output string:"+ outputStr);
}
Cheers
Vinu
"et" <eagletender2001@.yahoo.com> wrote in message
news:ODVkXK7NGHA.668@.TK2MSFTNGP11.phx.gbl...
> How can I strip out unwanted characters in a string before updating the
> database? For instance, in names & addresses in our client table, we want
> only letters and numbers, no punctuation. Is there a way to do this?
>
Function StripUnwantedChars(ByVal StringToStrip AsString) AsString
Dim stripped AsString
If StringToStrip <> "" Then
stripped = Regex.Replace(StringToStrip, "<(.|\n)+?>", String.Empty)
Return stripped
Else
Return ""
EndIf
EndFunction
Note : insert all the characters you want to strip inside the quotes.
For example, instead of :
stripped = Regex.Replace(StringToStrip, "<(.|\n)+?>", String.Empty)
use :
stripped = Regex.Replace(StringToStrip, "<!#(.|\n)+?>", String.Empty)
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"et" <eagletender2001@.yahoo.com> wrote in message news:ODVkXK7NGHA.668@.TK2MSFTNGP11.phx.gbl
..
> How can I strip out unwanted characters in a string before updating the da
tabase? For instance,
> in names & addresses in our client table, we want only letters and numbers
, no punctuation. Is
> there a way to do this?
>
Thanks, everyone, that's exactly what I was looking for.
"et" <eagletender2001@.yahoo.com> wrote in message
news:ODVkXK7NGHA.668@.TK2MSFTNGP11.phx.gbl...
> How can I strip out unwanted characters in a string before updating the
> database? For instance, in names & addresses in our client table, we want
> only letters and numbers, no punctuation. Is there a way to do this?
>