アドレスのジオロケーションをファイルに保存しようとしているところに問題があります。隠しラベルを使用して情報を転送しています。
私が持っているクライアント側のボタンイベントで:
function save() {
document.getElementById("hidLat").value = y;
document.getElementById("hidLon").value = x;
<% saveAddress s = save(); %>
}
そしてc#で私は持っています:
protected saveAddress save()
{
saveAddress s = new saveAddress();
s.latitude = hidLat.Value;
s.longitude = hidLon.Value;
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\\savedAddresses.txt", true))
{
file.WriteLine(s.latitude + " " + s.longitude);
file.Close();
}
return s;
}
ボタンをクリックすると、ファイルが作成されますが、何も保存されません。私はこれを正しく行っていますか、それともユーザー入力をファイルに書き込もうとするより良い方法はありますか?