設置asp:hiddenfield的值。但是當我訪問.aspx.cs頁面中hiddenfield的值時,它顯示空字符串。如何訪問C#中的隱藏字段值?我使用jQuery設置隱藏字段的值使用jquery
HTML
<asp:HiddenField runat="server" ID="hdnLat"/>
<asp:HiddenField runat="server" ID="hdnLng" />
JS
<script type="text/javascript">
function codeAddress() {
var address = $(".Hno").val() + " " + $(".Address").val() + "," + $(".City").val(); // Fetch Lattitude and logtittude for Using Google Map
//alert(address);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
var location = results[0].geometry.location;
//alert('LAT: ' + location.lat() + ' LANG: ' + location.lng());
var Lat = $('#<% =hdnLat.ClientID %>').attr('value', location.lat());
var lng = $('#<% =hdnLng.ClientID %>').attr('value', location.lng());
//alert($('#<% =hdnLat.ClientID %>').val() + ","+$('#<% =hdnLng.ClientID %>').val());
});
}
</script
這裏是我的按鈕在那裏我打電話jQuery的功能。
<asp:Button ID="btnUpdate" runat="server" CssClass="btn" Text="Submit" CausesValidation="True" ValidationGroup="Register2" OnClientClick="return codeAddress();"></asp:Button>
我創建btnUpdate_Click事件時頁面預渲染是。
private void InitializeComponent()
{
this.dlInvQueAnsV.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.dlInvQueAnsV_ItemDataBound);
this.dlInvQueAnsE.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.dlInvQueAnsE_ItemDataBound);
this.dgInvQue.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgInvQue_ItemDataBound);
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
this.btnRegister.Click += new System.EventHandler(this.btnRegister_Click);
this.lbCloseAccount.Click += new System.EventHandler(this.lbCloseAccount_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.ddlAdminComment.SelectedIndexChanged += new System.EventHandler(this.ddlAdminComment_SelectedIndexChanged);
this.btnSaveNote.Click += new System.EventHandler(btnSaveNote_Click);
this.btnSendCommentSMS.Click += new System.EventHandler(btnSendCommentSMS_Click);
this.btnSendCommentEmail.Click += new System.EventHandler(btnSendCommentEmail_Click);
}
你能張貼您的HTML代碼? – Mivaweb
這裏是我的html代碼 –
你如何訪問該字段的值?請發佈您的C#代碼。更好,如果你一次提供所有的細節... – Paolo