Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / July 2006

Tip: Looking for answers? Try searching our database.

WebChat - customizing code assistance from a NEEEEEEWBIE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dmitcha - 24 Jul 2006 19:54 GMT
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
Steve C. Orr [MVP, MCSD] - 24 Jul 2006 23:31 GMT
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.

Signature

I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

> 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
[quoted text clipped - 39 lines]
> Thank you very much in advance for any assistance!  So sorry for the
> incredibly green questions. dma
dmitcha - 25 Jul 2006 17:15 GMT
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>

> I'm flattered you like WebChat so much.
>
[quoted text clipped - 74 lines]
> > Thank you very much in advance for any assistance!  So sorry for the
> > incredibly green questions
dmitcha - 25 Jul 2006 00:56 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.