I have an issue regarding some interaction between Javascript and ASP.net control.
In javascript I get the innerHTML of a content editable like this :
var text = document.getElementById('corps').innerHTML;
document.getElementById('corpsToServer').value = text;
document.getElementById('callingServer').click();
This call an action on a click event for an ASP.NET updatePanel that call the serveur side of my application :
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server">
<br />
<asp:TextBox CssClass="serveurNeeded" runat="server" ID="corpsToServer" ClientIDMode="Static" ></asp:TextBox>
<br />
<asp:TextBox CssClass="serveurNeeded" ID="recup" runat="server" ClientIDMode="Static">
</asp:TextBox>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="callingProlexis" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:Button CssClass="serveurNeeded" ID="callingProlexis" runat="server" OnClick="tryReturn"
ClientIDMode="Static" Text="callhim" />
</form>
Then the call is like this :
<script language="C#" type="text/C#" runat="server">
public void tryReturn(object sender, EventArgs e)
{
prolexisIMPL proxy = new prolexisIMPL();
string getCorpsText = corpsToServer.Text;
string retourTest = proxy.tryThis(getCorpsText);
recup.Text = retourTest;
UpdatePanel1.Update();
ScriptManager.RegisterClientScriptBlock(this, GetType(), "mykey", "afterServerReturn();", true);
}
</script>
I have figure that it is the passing of innerHTML that make me get an error 500 from the server. Some post told that it is a validation issue to prevent injection from user side, but configuring the :
ValidateRequest="false"
is a bad idea and does not work.
How can I manage to send my innerHTML to the server side without this error showing up ? Something Like him pretending it's just a string and the tag are just part on the string, not html or javascript injection.
Configuration are ASP.NET MVC 4.0 without code behind, Vanilla Javascript, IE5.
EDIT : the error :
Sys.Webforms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was : 500