问题描述
protected void btn_add_Click(object sender,EventArgs e)
{
Create_property prp = new Create_property();
prp.client_id = 。会话[ ID]的ToString();
prp.vehicle_id = ddl_vehicle.SelectedValue.ToString();
prp.time = txt_hour.Text + : + txt_minit.Text + :00;
prp.time2 = txt_last_hour.Text + : + txt_last_minit.Text + :00;
串[]海峡= new string [2];
str = txt_date.Text.Split(' - ');
prp.date = str [2] +/+ str [ 1] +/+ str [0];
ds = Other_logic.display_plaback_map(prp);
----- - 在这里创建数据集记录数组---------
}
protected void btn_add_Click(object sender, EventArgs e)
{
Create_property prp = new Create_property();
prp.client_id = Session["id"].ToString();
prp.vehicle_id = ddl_vehicle.SelectedValue.ToString();
prp.time = txt_hour.Text +":"+ txt_minit.Text+":00";
prp.time2 = txt_last_hour.Text +":"+ txt_last_minit.Text+":00";
string[] str = new string[2];
str = txt_date.Text.Split('-');
prp.date = str[2] + "/" + str[1] + "/" + str[0];
ds = Other_logic.display_plaback_map(prp);
-------create array here of data set record---------
}
<script type="text/javascript">
function initialize() {
var lat ="array value";
var lon = "array value";
var image= "~/Upload/Vehicle2091231993.jpg";
var myLatlng = new google.maps.LatLng(lat, lon) // This is used to center the map to show our markers
var mapOptions = {
center: myLatlng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng
});
marker.setMap(map);
}
</script>
创建数组后的
c#文件比我想将数组传递给java脚本并将一个数组值再一个给var lat和var longi
after create array in c# file than i want to pass array to java script and give one bye one array value to var lat and var longi
推荐答案
to pass an array from server side to access it from client side we can use RegisterArrayDeclaration method.
Here is a simple example
在您的代码中,您可以使用类似的方法,
protected void Page_Load(object sender, EventArgs e)
{
RegisterArrayDeclaration(MyArray,'Welcome');
RegisterArrayDeclaration(MyArray,'Hai ');
RegisterArrayDeclaration(MyArray,'Hello');
RegisterArrayDeclaration(MyArray,'Best');
RegisterArrayDeclaration(MyArray,'超级');
}
您可以从客户端访问此数组Javascript代码,
In your code behind you can use the method like,
protected void Page_Load(object sender, EventArgs e)
{
RegisterArrayDeclaration("MyArray", "'Welcome'");
RegisterArrayDeclaration("MyArray", "'Hai'");
RegisterArrayDeclaration("MyArray", "'Hello'");
RegisterArrayDeclaration("MyArray", "'Best'");
RegisterArrayDeclaration("MyArray", "'Super'");
}
You can access this array from client side Javascript code,
for (var i = 0; i < MyArray.length; i++) {
alert(MyArray[i]);
}
这篇关于将数组从aspx.file传递给javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!