这是我的代码:
String url = "http://blablabla.blablabla.blabla/blabla/bla";
String html_sonuc;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()))
{
html_sonuc = sr.ReadToEnd();
sr.Close();
}
////////////Script Kodu//////////////
string script = @" function layerCek({0}) {
var features = geojson.read({0});
var bounds;
if (features) {
if (features.constructor != Array) {
features = [features];
}
for (var i = 0; i < features.length; ++i) {
if (!bounds) {
bounds = features[i].geometry.getBounds();
} else {
bounds.extend(features[i].geometry.getBounds());
}
}
vectors.addFeatures(features);
map.zoomToExtent(bounds);
} else {
alert('okuma hatası !');
}
}";
/////////////////////////////////////
string result = string.Format(script, html_sonuc);
ScriptManager.RegisterClientScriptBlock(
this.Page,
this.Page.GetType(),
"whatever",
result,
true);
我想在 aspx.cs 文件中使用 javascript。但我无法使用此代码。
string result = string.Format(script, html_sonuc); this line,I am taking error.
错误代码:FormatException 未被用户代码处理。
我该如何解决这个问题或者我尝试不同的方法来解决?