如何调用静态方法?我想从我创建的类中调用它,我想从IP获取位置.我已经宣布了它,但我需要做的是调用方法......如static...
为了跟你说实话,我很困惑在这里,我需要实例化address,city等等?
到目前为止我已经这样做了;
LocationTools.cs
public static class LocationTools
{
public static void GetLocationFromIP(string address, out string city, out string region, out string country, out double? latitude, out double? longitude)
{
Run Code Online (Sandbox Code Playgroud)
Home.cs
public string IPAPIKey
{
get
{
return WebConfigurationManager.AppSettings["IPAPIKey"];
}
}
////To get the ip address of the machine and not the proxy use the following code
static void GetLocationFromIP()
{
string strIPAddress = Request.UserHostAddress.ToString();
strIPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIPAddress == null || strIPAddress …Run Code Online (Sandbox Code Playgroud) 我已经尝试使用谷歌地图标记管理器,但我似乎每次都打砖墙,我按照如何在谷歌文档上创建markermanager的教程,但似乎没有什么对我有用,这是一个问题,我是如何代码写的?这里没有想法,此刻我已经设置了一个基于latlng在地图上下拉的标记.
有人可以尝试实施教程代码并为我找到一个有效的解决方案吗?它让我很生气.
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<div id="map_canvas" style="width:500px; height:500px;"></div>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
@*<script src="../../Scripts/markermanager.js" type="text/javascript"></script>*@
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP // map view, can be set to satellite, street, roadview, aerialview
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
animation: google.maps.Animation.DROP,
title: "Uluru (Ayers Rock)"
});
marker.setMap(map);
}
$(document).ready(function () {
initialize();
});
</script>
Run Code Online (Sandbox Code Playgroud) javascript google-maps google-maps-api-3 google-maps-markers
我正在尝试将元素的背景设置为no-repeat- 我尝试了以下方式,但它似乎什么都不做,我在哪里出错?它在a链接上显示图像很好.我正在隐藏文本链接text-indent以使其脱离页面(隐藏它)但隐藏它也隐藏了背景图像.有没有办法试图隐藏链接,只显示bg图像?下面是我到目前为止所做的 - 我只需要一些指导来克服这个问题 - 相对较新的jQuery.
<script type="text/javascript"> //Looking for every td a element and alerting it out on page (popup)
$('.AspNet-DataList td a').each(function (index) {
//alert(index + ': ' + $(this).text());
var submitEl = $(".AspNet-DataList td a")
//.parent('.AspNet-DataList td a')
.css('background', 'url(/assets/img/radarstep' + (index + 1) + 'dark.png)', 'backgroundRepeat:', 'no-repeat');
});
Run Code Online (Sandbox Code Playgroud)
当我在firebug中查看它时,td a这是来自jQuery css 的元素.即使no-repeat从这里设置背景也不起作用,在主css文件中我尝试添加高度和宽度 - 似乎不起作用.现在很困惑.
<a id="ctl07_HealthAndSafetyRadarForm_Wizard_SideBarContainer_SideBarList_SideBarButton_5" href="javascript:__doPostBack('ctl00$ctl07$HealthAndSafetyRadarForm_Wizard$SideBarContainer$SideBarList$ctl05$SideBarButton','')" style="background: url("/assets/img/radarstep6dark.png") no-repeat scroll 0 0 transparent;">Review</a>
//main.css
.AspNet-DataList …Run Code Online (Sandbox Code Playgroud) 我有一个脚本,我想将日期格式化为短日期格式,即:
2013年7月3日或7月3日13日,第一个日期格式在Chrome中呈现,但每隔一个浏览器不呈现 - 它显示日期月份名称和年份.
function dateFormatter(date) {
return date.toLocaleDateString();
}
Run Code Online (Sandbox Code Playgroud)
有点混淆为什么会发生这种情况.是因为浏览器不支持tolocalDateString();
我是否需要构建自定义日期字符串才能使其正常工作?
对不起,如果它有点模糊 - 我已经看过W3C网站,但有时不相信该网站.
以下脚本未在IE7中运行,但在IE 8 + 9和所有其他浏览器中运行良好.即使放入alert("something");不起作用 - 我有另一个脚本工作正常,并在IE 7完美运行.
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
Run Code Online (Sandbox Code Playgroud)
我错过了DOCTYPE吗?这是下面的脚本;
var formPageTitle = $("div.hsRadarform td h3").text();
$('.AspNet-DataList td a').each(function (index) {
var listElementText = $(this).text();
var shade = "faint";
if(formPageTitle.toLowerCase() == listElementText.toLowerCase()) {
shade = "dark";
}
//adding the numbered circles here using jQuery
$(this).css({
'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
'background-repeat': 'no-repeat',
'height': '25px',
'width': '25px',
});
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试验证用户选择日期的两个输入框 - 我设法远远限制用户选择之前的日期,如果他们选择第一个文本框作为今天的日期,下一个输入框必须是一天未来(未来日期)
提交时我试图让它验证,所以如果你不选择其中一个输入框,它会给你一个错误信息.
<asp:Label ID="lblPickupDate" runat="server" Text="Pick-up Date" CssClass="lblPickup"></asp:Label>
<input type="text" class="datePicker" id="validBeforeDatepicker" value="Please select a date" name="pickupdate" /> <span class="ui-icon ui-icon-calendar"></span>
<asp:Label ID="lblReturnDate" runat="server" Text="Return Date" CssClass="lblReturnDate"></asp:Label>
<input type="text" class="datePicker" id="validAfterDatepicker" value="Please select a date" name="returdate" /> <span class="ui-icon ui-icon-calendar"></span>
$(function () {
$("#validBeforeDatepicker").datepicker({
showOn: "button",
buttonImage: "/assets/img/calendar.gif",
buttonImageOnly: true,
minDate: 0,
required: true,
message: "This is a required field",
dateFormat: 'dd-mm-yy',
onClose: function() {$(this).valid();}
});
});
$(function () {
$("#validAfterDatepicker").datepicker({
showOn: "button",
buttonImage: "/assets/img/calendar.gif",
buttonImageOnly: true,
minDate: …Run Code Online (Sandbox Code Playgroud) 我里面ul有7个li.我知道我可以设计第一个和最后一个li但是可以设置最后3个li的样式,所以文字是不同的颜色?这是我第一次遇到这个问题/困境.我已经google了一下,并没有找到真正帮助我的东西.
<div class="international-portfolio">
<div class="international-portfolio-title"> Sales Representation International</div>
<ul class="nobullet inline int-portfolio ">
<li class="excelsior-hotel-ernst first">
<li class="le-mas-candille">
<li class="mandarin-oriental-hotel-group-worldwide">
<li class="victoria-jungfrau-grand-hotel-spa">
<li class="palace-luzern">
<li class="eden-au-lac">
<li class="bellevue-palace last">
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
香港专业教育学院更新了编码 - 尝试解决方案,但目前没有工作,但将坚持下去.
我在这里遇到了一个问题,我希望左侧菜单在页面上某个点到达时向下滑动并始终保持在顶部尝试使用jQuery执行此操作.固定在css中的位置有效,但在向下滑动页面时它不会停留在窗口的顶部,留下一个很大的白色间隙.jQuery新手在这里......
我收到这个错误;
$(this).offset() is null
Run Code Online (Sandbox Code Playgroud)
完整代码在这里
$(document).ready(function () {
$(window).scroll(function (event) {
var container = this;
var msie7 = $.browser.msie && $.browser.version < 8;
if (!msie7) {
var top = $(this).offset().top - parseFloat($(this).css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
var y = $(this).scrollTop() + 10;
if (y >= top) {
$(container).find("#dvContentAlpha").addClass('LeftMenuFixed');
} else {
$(container).find("#dvContentAlpha").removeClass('LeftMenuFixed');
}
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
CSS
#dvContentAlpha
{
width: 145px;
float: left;
margin-right: 35px;
position:fixed;
}
.LeftMenuFixed {
float: left;
font-weight: bold;
position: fixed;
top: 10px;
width: …Run Code Online (Sandbox Code Playgroud) 我似乎看不出问题出在我的连接字符串中,字符串中有 " 我什至尝试按照 stackoverflow 上的建议添加单引号,但它似乎仍然没有做任何事情。
以下是我的连接字符串,出于安全原因,取出并重命名了实际信息;
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=IP ADDRESS;Initial Catalog=DB NAME;integrated security=False;Persist Security Info=True;User ID=USERID;Password=PASSWORD" providerName="System.Data.SqlClient" />
<add name="ENTITYNAME" connectionString="metadata=res://*/ModelName.csdl|res://*/ModelName.ssdl|res://*/ModelName.msl;provider=System.Data.SqlClient;provider connection string=IPADDRESS"Data Source=IP ADDRESS;initial catalog=DB NAME;integrated security=False;MultipleActiveResultSets=True;App=EntityFramework;User ID=USERNAME;Password=PASSWORD"" providerName="System.Data.EntityClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud) c# connection-string database-connection datasource web-config
jquery ×4
css ×3
javascript ×3
c# ×2
datasource ×1
date ×1
datepicker ×1
datetime ×1
google-maps ×1
jquery-ui ×1
offset ×1
scroll ×1
string ×1
validation ×1
web-config ×1