嗨,提前致谢,
我在 c# 中填充 asp:label 并显示一些纬度/经度范围边界,然后进行验证。
ASP:
<script type="text/javascript" language="javascript">
window.bound = "<%= this.javaSerial.Serialize(this.rangeLat_Bounds) %>";
//alert(bound);
</script>
.
.
.
<asp:TabPanel ID="TabPanelLatLongCoord" runat="server" HeaderText="Lat/Long" TabIndex="1">
<ContentTemplate>
<div class="coord-btn btnLat_Long">
<asp:Button ID="btnDd" runat="server" Text="D.d" CssClass="coordinate-btn black" OnClick="Dd_Click" TabIndex="1" />
<asp:Button ID="btnDMS" runat="server" Text="DMS" CssClass="coordinate-btn black" OnClick="DMS_Click" TabIndex="1" />
<asp:Button ID="btnDMm" runat="server" Text="DM.m" CssClass="coordinate-btn black" OnClick="DMm_Click" TabIndex="1" />
</div>
<br />
<ul>
<li><span class="container-label">
<asp:Label ID="lblLat" runat="server" Text="Latitude" TabIndex="1"></asp:Label>
</span>
<asp:TextBox ID="txtLat" runat="server" CssClass="container-input-field" SkinID="NumTextUpDown" TabIndex="1"></asp:TextBox>
<asp:Label ID="rangeSetUp_Lat" runat="server" Text=""></asp:Label>
<asp:CustomValidator ID="Lat_Validator" runat="server" ControlToValidate="txtLat"
CssClass="errorMessage" ToolTip="Wrong Latitude Format" ClientValidationFunction="validate_Lat" TabIndex="1">
<img alt="" src="images/no.png" />
</asp:CustomValidator>
<asp:CustomValidator ID="RangeLat_CustomValidator" runat="server" ControlToValidate="txtLat"
CssClass="errorMessage" ToolTip="Latitude Out Of Range" ClientValidationFunction="rangeLat_validator" TabIndex="1">
<img alt="" src="images/no.png" />
</asp:CustomValidator>
</li>
<li><span class="container-label">
<asp:Label ID="lblLon" runat="server" Text="Longitude" TabIndex="1"></asp:Label>
</span>
<asp:TextBox ID="txtLon" runat="server" CssClass="container-input-field" SkinID="NumTextUpDown"></asp:TextBox>
<asp:Label ID="rangeSetUp_Lon" runat="server" Text="" TabIndex="1"></asp:Label>
<asp:CustomValidator ID="Lon_Validator" runat="server" ControlToValidate="txtLon"
CssClass="errorMessage" ToolTip="Wrong Longtitude Format" ClientValidationFunction="validate_Lon">
<img alt="" src="images/no.png" />
</asp:CustomValidator>
</li>
</ul>
</ContentTemplate>
</asp:TabPanel>
C#
protected void Dd_Click(object sender, EventArgs e)
{
.
.
.
Ranges range = new Ranges(rangeId);
String lowLat = parseOut(getCompassLat(range.LowLat));
String highLat = parseOut(getCompassLat(range.HighLat));
String rangeLat_Bounds = lowLat + " - " + highLat;
rangeSetUp_Lat.Text = rangeLat_Bounds;
JavaScriptSerializer js_serializer = new JavaScriptSerializer();
.
.
.
}
外部JS:
function rangeLat_validator(oSrc, args) {
//var bound = <%= this.javaSerial.Serialize(this.rangeLat_Bounds) %>;
var input = args.Value;
alert(window.bound);
}
当用户单击不同的按钮时,它会将 asp:label 重新格式化为纬度和经度的不同格式。问题是我无法在 JS 中获取 rangeSetUp_Lat ID 值。