English 中文(简体)
如何建立协会。 Java年网服务器时间
原标题:How to set ASP.NET server time in Javascript

你们如何将文字箱价值设定为相当于日期。 Now现在吗? 我审判了这些人。

$( #LastUpdatedTime ).val( <%= System.DateTime.Now %> );
$( #LastUpdatedTime ).val( <%= System.DateTime.Now.ToString() %> );

两者都对字面的字面上加起来;%= 系统。 时间......而不是时间。

问题回答

添加一只 as印功能,简单地将服务器标签归还,然后从你的档案中称这一功能。 i.e. 在协会补充:

function GetTimeNow () { return  <%= System.DateTime.Now.ToString() %> ;}

你们可以把服务器标签放在 j印档案中。

你们必须把该守则列入协会处理的文件。 NET发动机,例如你的文件。

(有可能配置服务器,使基础设施建设成为可能。) NET发动机还处理卷宗,但这不是一个好的解决方案。 Java字档案比普通页面更加贴切,因此无法确定服务器在使用档案时执行代码。

Do you have them inside <script> tags on the aspx page?

The aspx page should look something like this

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
    <form id="form1" runat="server">

<script type="text/javascript">
    //put your JAVASCRIPT here
    $( #LastUpdatedTime ).val( <%= System.DateTime.Now %> );
    $( #LastUpdatedTime ).val( <%= System.DateTime.Now.ToString() %> );
</script>
    </form>
</body>
</html>

该法典是罚款的。 问题是:<条码>和>;%=系统。 日期: 现在 %>代码不作为服务器侧码。 网页的其余部分也一样?

Edit: Since it s in an external JS file, you could always rename the ".js" file to ".aspx" so that ASP.Net would start processing it. Then you d just have to change your <script> tags to use the ".aspx" name instead.

另一种选择是将服务器召集起来,通过伙伴关系发送“js”档案。 净额手递。

如何在主机主角主页上写出时间

<script type="text/javascript">
var now = <%= System.DateTime.Now %>;
</script>

之后

$( #LastUpdatedTime ).val(now);

你只是需要确保你恰当地点名,以便使外部档案中的联合材料从全球范围获得价值。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签