❔ Incurable ERROR ???

I am trying to Post a database strings and ints to a webpage using C# I keep getting
System.FormatException: 'Input string was not in a correct format.'
System.FormatException: 'Input string was not in a correct format.'
The line that triggers this is
byte[] data = Encoding.UTF8.GetBytes(string.Format(pageData));
byte[] data = Encoding.UTF8.GetBytes(string.Format(pageData));
And it points to this static string Line 52
"<script type = 'text/javascript'>" +
Line 40: " var data = " +
"[{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}] " +
" var container = document.getElementById('Online Servers');" +
Line 52: " var hot = new Handsontable(container, {data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true});" +
"<script type = 'text/javascript'>" +
Line 40: " var data = " +
"[{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}] " +
" var container = document.getElementById('Online Servers');" +
Line 52: " var hot = new Handsontable(container, {data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true});" +
Now when i fix the Line 52 With {{}} Line 40 does the same but when there both fixed i get nothing on the page its blank
9 Replies
ⱧØⱠɎ₴₵ⱧɎ₮₮
This is What it wants i guess
"<script type = 'text/javascript'>" +
" var data = " +
"[{{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}}] " +
" var container = document.getElementById('Online Servers');" +
" var hot = new Handsontable(container, {{data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true}});" +
"<script type = 'text/javascript'>" +
" var data = " +
"[{{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}}] " +
" var container = document.getElementById('Online Servers');" +
" var hot = new Handsontable(container, {{data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true}});" +
Thinker
Thinker15mo ago
the issue (I assume) is the fact you have unescaped {} in your code Also please god use raw strings literals
"""
<script type = 'text/javascript'>
var data = [{{
...
}}]
"""
"""
<script type = 'text/javascript'>
var data = [{{
...
}}]
"""
ⱧØⱠɎ₴₵ⱧɎ₮₮
Yes so i correct it with the following but then the it doesnt work nothing happens @🌈 Thinker 🌈 Raw Strings??? all code is lit in errors
Thinker
Thinker15mo ago
what's your language version
Thinker
Thinker15mo ago
oh wait put the ending """ on its own line
ⱧØⱠɎ₴₵ⱧɎ₮₮
Nope same but i figured it out I put it all in one line with out the "code" + next line etc and it worked. so its string webpage = "Webpagecode"; webpage showed and worked. That makes no sense at all now its all working as i hit enter to put them in seperate lines. with " + and it still works Oh shit i am on version 10 not 11 fixed. thanks @🌈 Thinker 🌈
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?