I want to access java script’s return value , which in is in a variable and a label, i want to use it in .cs file, how do i do that? I have fetch the out put of javascript in a variable and also a label control of asp.net… I get the values both the ways, but in need it .cs file to save it in my data bsae, help me please.. Thank u
<script language=Javascript>
function setup_ip(json) {
var htmlx = " Your IP Address: <b>" + json.IP;
htmlx += "</b> | Country: " + json.countryName;
if (json.cityName != "Unknown" || json.regionName != "Unknown") {
htmlx += " | City: " + json.cityName + " / " + json.regionName;
var s = " | City: " + json.cityName + " / " + json.regionName;
} else {
htmlx += " | Your Time: " + json.localTimeZone;
}
$("#myipx").html(htmlx);
// $('#<%= lbl1.ClientID %>').text(htmlx);
$('#<%= lbl1.ClientID %>').text(s);
// var txtCountry = document.getElementById('<%=lbl1.ClientID %>');
}
$(document).ready(function() {
EasyjQuery_Get_IP("setup_ip", "full");
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="inner">
<p class="welcome-message">
<a href="http://www.easyjquery.com/detect-get-clients-ip-address-country-using-javascript-php/"id="topid" title="Javascript, PHP jQuery API Detect Clients IP Address and Country - Geo Location" >
<asp:Label ID="myipx" runat="server" ClientIDMode="Static"></a></asp:Label>Detecting Clients IP Address - Country - City</span>
<br />
<asp:Label ID="lbl1" runat="server" ClientIDMode="Static"></asp:Label>
</p>
<asp:TextBox ID="txtCountry" runat="server"></asp:TextBox>
<!-- END #footer-texture -->
</div>
</div>
</form>
</body>
To use this values you have following options :
1.)As label is your server side control you can easily access label text value in .cs file so main issue with javascript variable here you can assign this value to asp:hidden field so you can also access this in .cs file like :
cs file :
2.)Another option you can use pagemethod here and pass both values as parameter to .cs file.
javascript :
CS file :
Hope it helps you.