WebChat - customizing code assistance from a NEEEEEEWBIE

D

dmitcha

Hi, I just added Steve Orr's incredible WebChat control to my page (ASP.NET
2.0), but I'm not advanced enough to correctly add the additional code for
filters and identifying the user (I used CreateUserWizard for secure log-in).

1) TEXT FILTER. What is the correct syntax for the Chatter event to filter
words? Here is the sample code Steve kindly supplied in his article:

Protected Sub WebChat1_Chatter(ByRef ChatText As String) _

Handles WebChat1.Chatter

'You can replace bad words...

ChatText = ChatText.Replace("hell", "h***")

'...or spruce things up with emoticons

ChatText = ChatText.Replace(":)", _

"<img src='smiley.jpg' title=':)' />")

End Sub

I have placed this in the Script section at the top. I, unfortunately, do
not know how to create a syntactically correct single list with many replace
requests, and my compiler keeps kicking up the "Handle..." line as a syntax
error.

2) LIVE COMMENT SUPERVISION. Is there a way to supervise content live to
prevent certain posts from ever posting and to even block users)?

3) USER ID. Where does the provided code snippet go for the UserName
property?

Here is Steve's starter snippet, but it doesn't seem to work inside of the
CC1 code, and if I try to add it as a Protected Sub in the Script, the
compiler says I need a declaration.

4) CHAT ROOM ACCESS TOGGLE. Is there code to allow the Webmaster to open
and close the Chat Room for use?

Thank you very much in advance for any assistance! So sorry for the
incredibly green questions. dma
 
S

Steve C. Orr [MVP, MCSD]

I'm flattered you like WebChat so much.

The Handles statement should be on the same line as the sub declaration.

Try this code:

Protected Sub WebChat1_Chatter(ByRef ChatText As String) Handles WebChat1.Chatter

System.Diagnostics.Debug.WriteLine("Page detected chatter event from WebChat control")

'The page will not be rendered

'after this event since it's a callback

'but ChatText will be displayed in the WebChat control.

'So you can replace bad words...

ChatText = ChatText.Replace("hell", "h***")

'...or spruce things up with emoticons

ChatText = ChatText.Replace(":)", _

"<img src='smiley.jpg' title=':)' />")

End Sub

As for the optimal way to filter a variety of words, well that's up to you to decide since the control doesn't directly implement that. I might suggest using one or more regular expressions to do the work. You may be able to find some useful regular expressions from google in case you're not very experienced with them.

You can set the WebChat's username property from the page load event or pretty much wherever else you want in the code behind.
WebChat1.UserName = sName

There is not currently a live content supervision feature built directly into the control, but you should be able to build one in yourself since all chat content gets filtered through the Chatter event. You could hook into this event and do pretty much any kind of filtering or supervision you want.
 
D

dmitcha

Well, I wasn't exactly expecting a response from you, yourself! Thank you
very much for the additional tips. Okay, going back in to try again. Please
be beyond flattered , Steve; I've been telling everyone today about this
amazing tool. You are BRILLIANT. dma
 
D

dmitcha

Thanks, again, Steve; I gave both a shot, and unfortunately, neither works as
a cut-and-paste. I'm not clear enough on Visual Basic .NET commands to
figure out why the syntax errors keep popping up. The debugger wants the
Handles clause to have a "WithEvents variable defined in the containing type
or one of its base types." And unfortunately, I am getting a similar error
when I try to set the property in the Page Load event.

It seems that there will need to be some kind of Dim statement for WebChat1
for me to proceed, but I'm not even sure what kind of information I'm
handling here...

I'm guessing my list of requests is not even an hour's worth of work for
someone with experience (if I can just get the syntax for the filter list, I
can party on from there); is there anyone who might be able to tweak this
script remotely for a Peet's online Coffee Card or PayPal payment? Thank
you! dma

<%@ Page Language="VB" MasterPageFile="~/homepage.master" Title="Hollywood
Calls—Home" %>

<script runat="server">

Protected Sub LoginView1_ViewChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

End Sub

Protected Sub NewUserLinkButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs)

End Sub

Protected Sub WebChat1_Chatter(ByRef ChatText As String) Handles
WebChat1.Chatter

System.Diagnostics.Debug.WriteLine("Page detected chatter event from
WebChat control")

'The page will not be rendered

'after this event since it's a callback

'but ChatText will be displayed in the WebChat control.

'So you can replace bad words...

ChatText = ChatText.Replace("hell", "h***")

'...or spruce things up with emoticons

ChatText = ChatText.Replace(":)", "<img src='smiley.jpg' title=':)'
/>")

End Sub
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top