سؤال

I am using Tinymce in my web page and in client side every thing works fine. But when I try to access the tinymce textbox in code behind the page control doesnot render. I mean Page load Didn't Render. Here is my HTML Code

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RichText.aspx.cs" Inherits="TESTING.RichText"
ValidateRequest="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
   <title>Rich Text</title>
<script src="<%=ResolveClientUrl("~/Script/jquery-ui-1.7.1.custom.min.js") %>" type="text/javascript"></script>
<script type="text/javascript" src="Scirpt/tinymce/jscripts/tiny_mce/tiny_mce.js"> </script>
<script type="text/javascript" src="Scirpt/tinymce/jscripts/tiny_mce/InitializeRichTextBox.js"> </script>
</head>
<body>
<form id="form1" runat="server">
<div style="width: 400px">
    <div style="height: 100px; width: 100%;">
        &nbsp;</div>
    <asp:TextBox ID="TextBox1" runat="server" TextMode="multiline" CssClass="RichTextBox"
        Width="150px"></asp:TextBox>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</form>
</body>
</html>

Here is my Code Behind code

   using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Web;
   using System.Web.UI;
   using System.Web.UI.WebControls;

   namespace TESTING
   {
     public partial class RichText : System.Web.UI.Page
     {
      protected void Page_Load(object sender, EventArgs e)
      {

      }

      protected void Button1_Click(object sender, EventArgs e)
      {
        string here = TextBox1.Text;
      }
  }
}

When i leave empty text then Page Load renders and when I write something and click on Button then this error occurs A potentially dangerous Request.Form value was detected from the client (TextBox1="<ul><li><em><span ..."). I tried to find the solution in internet but unable to find the solution. Please help me out to find the solution.

هل كانت مفيدة؟

المحلول

Add this in Web.config

   <configuration>
    <system.web>
     <compilation debug="true" targetFramework="4.0"/>
     <httpRuntime requestValidationMode="2.0"/>
    </system.web>
   </configuration>

and add ValidateRequest = "false" in Page directive like this

     <%@ Page Language="C#" AutoEventWireup="true" 
     CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %> 

for your reference click here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top