从下拉控件调用方法 [英] Calling a method from a drop down control
问题描述
如果我在ASP.NET 2.0中运行以下代码,则会失败并显示对象
必需错误,我不明白为什么。
有人能告诉我为什么会失败吗?然后,如果我能得到一个
的答案,我实际上更愿意运行一个C#方法而不是
a javascript one,并想知道如何设置它(但是
我也得到同样的错误)。
< select id =" cbCarriers" onchange =" javascript :test();">
< option value =''241''> 3GP< / option>
< option value ='''441''> AAC< / option>
< option value =''1115''> AB1< / option>
< / select>
< script type =" javascript">
功能测试()
{
alert(this);
}
< / script>
7月13日上午11:13,Doogie< dnlwh ... @ dtgnet.comwrote:
如果我在ASP.NET 2.0中运行以下代码,它将失败并显示对象
必需错误,我不明白为什么。
有人能告诉我为什么会失败吗?然后,如果我能得到一个
的答案,我实际上更愿意运行一个C#方法而不是
a javascript one,并想知道如何设置它(但是
我也得到同样的错误)。
< select id =" cbCarriers" onchange =" javascript :test();">
< option value =''241''> 3GP< / option>
< option value ='''441''> AAC< / option>
< option value =''1115''> AB1< / option>
< / select>
< script type =" javascript">
功能测试()
{
alert(" this");
}
< / script>
onchange =" test();"
并且不要这样做导航。键盘和鼠标轮的用户将会讨厌它。$ / b
至于.NET和C#,您将不得不在其他地方询问。
嗨!
Doogie< dn ****** @ dtgnet.comwrote:
[snip]
< select id =" cbCarriers" onchange =" javascript :test();">
^^^
[/ snip]
您是否尝试过删除空间我指着?
再见
7月13日下午4:13,Doogie< dnlwh .. 。@ dtgnet.comwrote:
如果我在ASP.NET 2.0中运行以下代码,它将失败并显示对象
必需错误,我不明白为什么。
有人能告诉我为什么会失败吗?然后,如果我能得到一个
的答案,我实际上更愿意运行一个C#方法而不是
a javascript one,并想知道如何设置它(但是
我也得到同样的错误)。
< select id =" cbCarriers" onchange =" javascript :test();">
< option value =''241''> 3GP< / option>
< option value ='''441''> AAC< / option>
< option value =''1115''> AB1< / option>
< / select>
< script type =" javascript">
功能测试()
{
alert(" this");
}
< / script>
尝试删除javascript :"来自你的函数的子句。它不需要
,因为onchange属性中的任何内容都会自动传递给JavaScript引擎,因为onchange是JavaScript。
>
If I run this code below in ASP.NET 2.0 it fails with an "Object
Required" error and I have no idea why.
Could someone tell me why this is failing? Then if I can get an
answer to that, I would actually prefer to run a C# method instead of
a javascript one and would like to figure out how to set that up (but
I get the same error doing that too).
<select id="cbCarriers" onchange="javascript: test();">
<option value=''241''>3GP</option>
<option value=''441''>AAC</option>
<option value=''1115''>AB1</option>
</select>
<script type="javascript">
function test()
{
alert("this");
}
</script>
On Jul 13, 11:13 am, Doogie <dnlwh...@dtgnet.comwrote:If I run this code below in ASP.NET 2.0 it fails with an "Object
Required" error and I have no idea why.
Could someone tell me why this is failing? Then if I can get an
answer to that, I would actually prefer to run a C# method instead of
a javascript one and would like to figure out how to set that up (but
I get the same error doing that too).
<select id="cbCarriers" onchange="javascript: test();">
<option value=''241''>3GP</option>
<option value=''441''>AAC</option>
<option value=''1115''>AB1</option>
</select>
<script type="javascript">
function test()
{
alert("this");
}
</script>onchange="test();"
And don''t do this for navigation. Keyboard and mousewheel users will
hate it.
As for .NET and C#, you will have to ask elsewhere.
Hi!
Doogie <dn******@dtgnet.comwrote:
[snip]
<select id="cbCarriers" onchange="javascript: test();">^^^
[/snip]
Have you tried and removed the space I''m pointing at?
bye
On Jul 13, 4:13 pm, Doogie <dnlwh...@dtgnet.comwrote:If I run this code below in ASP.NET 2.0 it fails with an "Object
Required" error and I have no idea why.
Could someone tell me why this is failing? Then if I can get an
answer to that, I would actually prefer to run a C# method instead of
a javascript one and would like to figure out how to set that up (but
I get the same error doing that too).
<select id="cbCarriers" onchange="javascript: test();">
<option value=''241''>3GP</option>
<option value=''441''>AAC</option>
<option value=''1115''>AB1</option>
</select>
<script type="javascript">
function test()
{
alert("this");
}
</script>Try removing the "javascript: " clause from your function. It''s not
needed, as anything within the onchange attribute is automatically
passed on to the JavaScript engine, as onchange is JavaScript.
这篇关于从下拉控件调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!