encode decode

Discussion in 'C#' started by moiseszaragoza, Dec 15, 2008.

  1. #1
    i am displaying HTML i have saved in the DB but i am updating that so it will store encoded HTML.

    but i need to display proper HTML in inside a text field.

    but when ever i press the submit btn it tells me it does not like it.

    SAMPLE ERROR MESSAGE
    
    
    [SIZE="4"]A potentially dangerous Request.Form value was detected from the client (DisplayText="<b>Tertyer</b>"). [/SIZE]Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case. 
    
    Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (DisplayText="<b>Tertyer</b>").
    
    
    
    
    Code (markup):

    I was wondering what i can do so that when i can encode b4 it gives me the error?
     
    moiseszaragoza, Dec 15, 2008 IP
  2. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #2
    The best way how to go about that is to use FCKEditor. This is a nice text editor and works great. It is free to use and you just copy the code into you website directory and you can use it to.

    On the webpage you copy:
    <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server">
    </FCKeditorV2:FCKeditor>

    And in the code behind you need to set the directory, set size and what all have to show in the toolbar
    If Not Page.IsPostBack Then
    FCKeditor1.BasePath = "~/fckeditor/"
    ' FCKeditor1.ToolbarSet = "Members"
    FCKeditor1.Width = 600
    FCKeditor1.Height = 300
    End If

    to access the info you just do
    FCKeditor1.value

    The website is www.fckeditor.net to download the code.
     
    islandhopper8, Dec 17, 2008 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    you would probably have to use javascript to encode it before the form submits.
     
    camjohnson95, Dec 20, 2008 IP
  4. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #4
    Set ValidateRequest="false" for the page

    <%@ Page ValidateRequest="false" Language="VB" ...... %>
     
    vihutuo, Dec 21, 2008 IP
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    yeh or do that if that is what u meant... it says right there in the error message.
     
    camjohnson95, Dec 22, 2008 IP