ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Get Label value after PostBack in ASP.Net using C# and VB.Net<p>Hey <a class="username" rel="nauna">nauna</a>,</p> <p>The issue is , Label is converted into span element and html elements like span and div do't have ViewState. So use HiddenField and store your value in HiddenField and get label value on PostBack.</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;https://maps.googleapis.com/maps/api/js?&amp;key=AIzaSyBE1J5Pe_GZXBR_x9TXOv6TU5vtCSmEPW4&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (p) { var LatLng = new google.maps.LatLng(p.coords.latitude, p.coords.longitude); var geocoder = geocoder = new google.maps.Geocoder(); geocoder.geocode({ &#39;latLng&#39;: LatLng }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[1]) { document.getElementById(&#39;&lt;%= hfLabelValue.ClientID %&gt;&#39;).value = &#34;&#34; + results[1].formatted_address; } } }); }); } else { alert(&#39;Geo Location feature is not supported in this browser.&#39;); } &lt;/script&gt; &lt;div&gt; &lt;asp:Button Text=&#34;GetLocation&#34; ID=&#34;btnGet&#34; runat=&#34;server&#34; OnClick=&#34;GetLocation&#34; /&gt; &lt;asp:HiddenField ID=&#34;hfLabelValue&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblAddress&#34; runat=&#34;server&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void GetLocation(object sender, EventArgs e) { string location = hfLabelValue.Value; lblAddress.Text = location; }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub GetLocation(sender As Object, e As System.EventArgs) Handles btnGet.Click Dim location As String = hfLabelValue.Value lblAddress.Text = location End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/mbv8TBo.gif" alt="" width="357" height="154" /></p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/737713/Get-Label-value-after-PostBack-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/737713/Get-Label-value-after-PostBack-in-ASPNet-using-C-and-VBNet/Fri, 14 Dec 2018 00:21:53 GMT