我在aspx页面上使用web用户控件来显示google地图上的位置,我将位置作为参数从ASPX页面加载事件和每次加载页面传递到I我完美地获取位置。如何刷新按钮点击Web用户控件
我必须更改位置,每当用户搜索特定位置点击ASPX页面上的“搜索”按钮时,我将位置传递给“搜索”按钮点击事件中的网络用户控件,但无法获取到Web用户控件的位置。
public partial class MapControl : System.Web.UI.UserControl
{
public List<string> MyLocation {get; set; }
protected void Page_Load(object sender, EventArgs e)
{
GeoCode geocode;
List<GMarker> markers = new List<GMarker>();
for (int i = 0; i < MyLocation.Count(); i++)
{
geocode = GMap1.getGeoCodeRequest(MyLocation[i]);
GLatLng gLatLng = new GLatLng(geocode.Placemark.coordinates.lat, geocode.Placemark.coordinates.lng);
GMap1.setCenter(gLatLng, 20, GMapType.GTypes.Normal);
GMarker oMarker = new GMarker(gLatLng);
markers.Add(oMarker);
//GMap1.Add(oMarker);
GListener listener = new GListener(oMarker.ID, GListener.Event.click, string.Format(@"function() {{ var w = new google.maps.InfoWindow(); w.setContent('<center>{0}</center>'); w.open({1}, {2});}}", "<b>" + MyLocation[i] + "</b>", GMap1.GMap_Id, oMarker.ID));
GMap1.Add(listener);
}
GMap1.Add(new GMapUI());
GMap1.GZoom = 10;
protected void Button1_Click1(object sender, EventArgs e)
{
List<string> locations = new List<string>();
for (int i = 0; i < ListView1.Items.Count; i++)
{
Label addressline1 = (Label)this.ListView1.Items[i].FindControl("addr1");
string addrloc = addressline1.Text;
locations.Add(addrloc);
}
MapControl mc = LoadControl("~/MapControl.ascx") as MapControl;
mc.MyLocation = locations;
}
而我包括在此web用户控件到Search.aspx文件,当我通过从页面加载事件其工作地点,但是当我试图通过从搜索按钮单击事件越来越Null值的位置分成Mylocations的价值Web用户控制为空..所以有什么办法来重新加载用户控件与新的位置。
你可以发布我们的代码?并且在页面加载事件中使用“ispostback” – Backtrack
您到目前为止尝试解决您的问题。 –