我没有得到javascript。你如何使用它? [英] I don't get javascript. How do you use it?

查看:68
本文介绍了我没有得到javascript。你如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。


我刚读完了两篇关于javascript的文章:
http://msdn2.microsoft.com/en-us/lib...23(VS.80).aspx


我在WIN XP Pro,SP2上尝试了VS2005,SP1,VB,.NET 2.0,ASP.NET 2.0中的一些javascript测试

。 br />

这真的很简单。我在页面上放了一个按钮并将onClick编码为

这个:

< asp:Button ID =" Button1" RUNAT = QUOT;服务器" Style =" z-index:103;左:528px;

位置:绝对;上:392px文本= QUOT;按钮和QUOT;的OnClick = QUOT; ShowCal" />


这是函数:

< script type =" text / javascript" language =" javascript">

函数ShowCal(){

var x = Button1.Style.z - index;

alert( x);

}

< / script>


它不会让我运行程序说 ''ShowCal''不是

的成员''ASP.default_aspx''"


如果javascript如此受欢迎,为什么我们不能使用它?


感谢任何帮助。


谢谢,

Tony

解决方案

JavaScript是客户端的。 ASP.Net按钮的OnClick事件是

寻找服务器端功能。在这种情况下,你最好的选择是使用

普通HTML按钮,然后从HTML

按钮的onclick事件中调用javascript事件。

-

希望这会有所帮助,

Mark Fitzpatrick

前微软FrontPage MVP 199?-2006

" Tony Girgenti" < tony(nospam)@ lakesideos.com写信息

新闻:************** @ TK2MSFTNGP06.phx.gbl ...


你好。


我刚读完了两篇关于javascript的文章:
http://msdn2.microsoft.com/en-us/lib...23 (VS.80).aspx


我在VS2005,SP1,VB,.NET 2.0,ASP.NET 2.0中尝试了一些javascript测试

在WIN XP专业版,SP2上。


这真的很简单。我在页面上放了一个按钮,并在其中编码onClick

,如下所示:

< asp:Button ID =" Button1" RUNAT = QUOT;服务器" Style =" z-index:103;左:528px;

位置:绝对;上:392px文本= QUOT;按钮和QUOT;的OnClick = QUOT; ShowCal" />


这是函数:

< script type =" text / javascript" language =" javascript">

函数ShowCal(){

var x = Button1.Style.z - index;

alert( x);

}

< / script>


它不会让我运行程序说 ''ShowCal''不是

的成员''ASP.default_aspx''"


如果javascript如此受欢迎,为什么我们不能使用它?


感谢任何帮助。


谢谢,

Tony



" Tony Girgenti" < tony(nospam)@ lakesideos.com写信息

新闻:************** @ TK2MSFTNGP06.phx.gbl ...


我在WIN XP Pro,SP2上尝试了VS2005,SP1,VB,.NET 2.0,ASP.NET 2.0中的一些javascript测试




这真的很简单。我在页面上放了一个按钮,并在其中编码onClick

,如下所示:

< asp:Button ID =" Button1" RUNAT = QUOT;服务器" Style =" z-index:103;左:528px;

位置:绝对;上:392px文本= QUOT;按钮和QUOT;的OnClick = QUOT; ShowCal" />


这是函数:

< script type =" text / javascript" language =" javascript">

函数ShowCal(){

var x = Button1.Style.z - index;

alert( x);

}

< / script>


它不会让我运行程序说 ''ShowCal''不是

的成员''ASP.default_aspx''"


如果javascript如此受欢迎,为什么我们不能用它?



因为你没有调用它...< asp:Buttonwill

的OnClick事件导致页面发布返回(除非你使用AJAX或类似的东西)

并尝试运行服务器端方法...


将代码更改为以下:


< asp:Button ID =" Button1" RUNAT = QUOT;服务器" Style =" z-index:103;左:528px;

位置:绝对;上:392px文本= QUOT;按钮和QUOT;的OnClientClick = QUOT; ShowCal();" />


Hello Mark和Mark。


我试过Mark Fitzpatrick的方式和Mark Rae''的方式。无论哪种方式,

都没有给出错误,但它没有做任何事情。


< input id =" Button1" style =" z-index:103;左:496px;位置:绝对;

顶部:392px"

type =" button"值= QUOT按钮"的onClick = QUOT; ShowCal;" />

< asp:Button ID =" Button2" RUNAT = QUOT;服务器" Style =" z-index:104;左:688px;

位置:绝对;上:392px文本= QUOT;按钮和QUOT;的OnClientClick = QUOT; ShowCal();" />


当我点击Button1时,它什么都不做,并在页面上放置一个错误。在IE屏幕底部的

并没有做任何事情。当我点击Button2时,我可以在IE屏幕底部看到

进度条,但它什么也没做。


谢谢,

Tony


" Mark Rae" < ma ** @ markNOSPAMrae.com写信息

新闻:英国************** @ TK2MSFTNGP06.phx.gbl ...
< blockquote class =post_quotes>
" Tony Girgenti" < tony(nospam)@ lakesideos.com写信息

新闻:************** @ TK2MSFTNGP06.phx.gbl ...


>我在WIN XP Pro,SP2上的VS2005,SP1,VB,.NET 2.0,ASP.NET
2.0中尝试了一些javascript测试。
<这很简单。我在页面上放了一个按钮并将onClick编码在其中
这样:
< asp:Button ID =" Button1" RUNAT = QUOT;服务器" Style =" z-index:103;左:528px;
位置:绝对;上:392px文本= QUOT;按钮和QUOT;的OnClick = QUOT; ShowCal" />

这是函数:
< script type =" text / javascript" language =" javascript">
函数ShowCal(){
var x = Button1.Style.z - index;
alert(x);
}
< / script>

它不会让我运行程序说'''ShowCal''不是
''ASP.default_aspx''" <的成员br />
如果javascript如此受欢迎,为什么不能使用它?



因为你没有调用它...< asp:Buttonwill

的OnClick事件导致页面发布返回(除非你使用AJAX或类似的东西

)并尝试运行服务器端方法...


将代码更改为以下:


< asp:Button ID =" Button1" RUNAT = QUOT;服务器" Style =" z-index:103;左:528px;

位置:绝对;上:392px文本= QUOT;按钮和QUOT; OnClientClick =" ShowCal();"

/>



Hello.

I just finished reading two articles about javascript here:
http://msdn2.microsoft.com/en-us/lib...23(VS.80).aspx

I tried some javascript testing in VS2005, SP1, VB , .NET 2.0, ASP.NET 2.0
on WIN XP Pro, SP2.

It''s real simple. I put a button on a page and coded the onClick in it like
this:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px;
position: absolute; top: 392px" Text="Button" OnClick="ShowCal" />

Here is the function:
<script type="text/javascript" language="javascript">
function ShowCal() {
var x = Button1.Style.z - index;
alert(x);
}
</script>

It won''t let me run the program saying "''ShowCal'' is not a member of
''ASP.default_aspx''"

If javascript is so popular, why can''t i use it?

Any help would be gratefully appreciated.

Thanks,
Tony

解决方案

JavaScript is client-side. The OnClick event of the ASP.Net button is
looking for a server-side function. Your best bet in this case is to use a
plain HTML button instead and call the javascript event from the HTML
button''s onclick event.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Tony Girgenti" <tony(nospam)@lakesideos.comwrote in message
news:Of**************@TK2MSFTNGP06.phx.gbl...

Hello.

I just finished reading two articles about javascript here:
http://msdn2.microsoft.com/en-us/lib...23(VS.80).aspx

I tried some javascript testing in VS2005, SP1, VB , .NET 2.0, ASP.NET 2.0
on WIN XP Pro, SP2.

It''s real simple. I put a button on a page and coded the onClick in it
like this:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px;
position: absolute; top: 392px" Text="Button" OnClick="ShowCal" />

Here is the function:
<script type="text/javascript" language="javascript">
function ShowCal() {
var x = Button1.Style.z - index;
alert(x);
}
</script>

It won''t let me run the program saying "''ShowCal'' is not a member of
''ASP.default_aspx''"

If javascript is so popular, why can''t i use it?

Any help would be gratefully appreciated.

Thanks,
Tony



"Tony Girgenti" <tony(nospam)@lakesideos.comwrote in message
news:Of**************@TK2MSFTNGP06.phx.gbl...

I tried some javascript testing in VS2005, SP1, VB , .NET 2.0, ASP.NET 2.0
on WIN XP Pro, SP2.

It''s real simple. I put a button on a page and coded the onClick in it
like this:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px;
position: absolute; top: 392px" Text="Button" OnClick="ShowCal" />

Here is the function:
<script type="text/javascript" language="javascript">
function ShowCal() {
var x = Button1.Style.z - index;
alert(x);
}
</script>

It won''t let me run the program saying "''ShowCal'' is not a member of
''ASP.default_aspx''"

If javascript is so popular, why can''t i use it?

Because you''re not calling it... The OnClick event of an <asp:Buttonwill
cause the page to post back (unless you''re using AJAX or something similar)
and try to run a server-side method...

Change your code to the following:

<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px;
position: absolute; top: 392px" Text="Button" OnClientClick="ShowCal();" />


Hello Mark and Mark.

I tried it both Mark Fitzpatrick''s way and Mark Rae''s way. Either way does
not give an error, but it does not do anything.

<input id="Button1" style="z-index: 103; left: 496px; position: absolute;
top: 392px"
type="button" value="button" onClick="ShowCal;" />
<asp:Button ID="Button2" runat="server" Style="z-index: 104; left: 688px;
position: absolute; top: 392px" Text="Button" onClientClick="ShowCal();" />

When i click Button1, it does nothing and puts an "Error on page" on the
bottom of the IE screen and does nothing. When i click Button2, i can see
the progress bar at the bottom of the IE screen, but it does nothing.

Thanks,
Tony

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uK**************@TK2MSFTNGP06.phx.gbl...

"Tony Girgenti" <tony(nospam)@lakesideos.comwrote in message
news:Of**************@TK2MSFTNGP06.phx.gbl...

>I tried some javascript testing in VS2005, SP1, VB , .NET 2.0, ASP.NET
2.0 on WIN XP Pro, SP2.

It''s real simple. I put a button on a page and coded the onClick in it
like this:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px;
position: absolute; top: 392px" Text="Button" OnClick="ShowCal" />

Here is the function:
<script type="text/javascript" language="javascript">
function ShowCal() {
var x = Button1.Style.z - index;
alert(x);
}
</script>

It won''t let me run the program saying "''ShowCal'' is not a member of
''ASP.default_aspx''"

If javascript is so popular, why can''t i use it?


Because you''re not calling it... The OnClick event of an <asp:Buttonwill
cause the page to post back (unless you''re using AJAX or something
similar) and try to run a server-side method...

Change your code to the following:

<asp:Button ID="Button1" runat="server" Style="z-index: 103; left: 528px;
position: absolute; top: 392px" Text="Button" OnClientClick="ShowCal();"
/>



这篇关于我没有得到javascript。你如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆