WebChat - customizing code assistance from a NEEEEEEWBIE

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default WebChat - customizing code assistance from a NEEEEEEWBIE

    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
    dmitcha Guest

  2. Similar Questions and Discussions

    1. Customizing an Accordion
      I am trying to figure out a way to customize an Accordion so that the VBoxes inside will remain open unless I click a triangle icon that I place on...
    2. customizing insert bar in DW 8
      I am trying to customize the insert bar in DW8. I have editted the insertbar.xml file, but no changes seem to "take". In fact, I can delete the...
    3. Customizing Toolbar in MX
      When I try to customize a toolbar in MX (running Panther), I can't remove buttons. I tried holding down the COMMAND key yet I still can't remove...
    4. Help! Dependent Lists with SQL Server (with code/db setup) assistance needed!
      Hey folks, i'm _trying_ to get a dependent list box example working from this example/tutorial found at...
    5. Brute Force Quickie Developer needs minor assistance finding code tool . . .
      Hello, I am new to Oracle. I've been programming various client and web based utilities for MS SQL for years, now we have an Oracle server and...
  3. #2

    Default Re: WebChat - customizing code assistance from a NEEEEEEWBIE

    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.


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



    "dmitcha" <dmitcha@discussions.microsoft.com> wrote in message news:3B60944F-C0A8-465D-9F22-17F0B4B4E55C@microsoft.com...
    > 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] Guest

  4. #3

    Default RE: WebChat - customizing code assistance from a NEEEEEEWBIE

    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
    dmitcha Guest

  5. #4

    Default Re: WebChat - customizing code assistance from a NEEEEEEWBIE

    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>

    "Steve C. Orr [MVP, MCSD]" wrote:
    > 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.
    >
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > [url]http://SteveOrr.net[/url]
    >
    >
    >
    > "dmitcha" <dmitcha@discussions.microsoft.com> wrote in message news:3B60944F-C0A8-465D-9F22-17F0B4B4E55C@microsoft.com...
    > > 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
    dmitcha Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139