button 怎样调用javascript
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
怎样点击时调用javascript中的函数? --------------------编程问答-------------------- 或者 怎样传一个参数给 函数Button1_Click --------------------编程问答--------------------
<script>
function javafunction()
{
alert('ok');
}
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="javafunction();" />
--------------------编程问答-------------------- this.Button1.Attribute.Add("onclick","alert('ssfdsfdsffdf');");
<script>
function javafunction()
{
alert('ok');
}
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javafunction();" />
--------------------编程问答-------------------- OnClientClick --------------------编程问答--------------------
完全正确 --------------------编程问答-------------------- 在page_load里边写这个
this.Button1.Attribute.Add("onclick","alert('ssfdsfdsffdf');");
--------------------编程问答-------------------- 错了修正一下
<script>
function javafunction()
{
alert('ok');
}
</script>
或者
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javafunction();" />
page_load中:
Button1.Attributes.Add("onclick","javafunction()");--------------------编程问答-------------------- 1:OnClientClick="javafunction();"
2:page_load
this.Button1.Attributes.Add("onclick","javafunction();"); --------------------编程问答-------------------- VS2003 --------
html:
<script>
function javafunction()
{
alert('ok');
}
</script>
c# CS code:
Button1.Attribute.Add("onclick","javafunction();");
VS2005 --------
html:
<script>
function javafunction()
{
alert('ok');
}
</script>
c# aspx code:
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javafunction();" /> --------------------编程问答-------------------- OnClick="Button1_Click" 中 能不能传另外的一个int型参数? --------------------编程问答-------------------- OnClientClick=“js函数名” --------------------编程问答-------------------- ding --------------------编程问答--------------------
当然可以呀,OnClientClick="javafunction(参数);" --------------------编程问答--------------------
顶
如果不添加Attribute 就引用不到方法 --------------------编程问答-------------------- OnClientClick="js" --------------------编程问答-------------------- js 怎样传参数给c#函数?
补充:.NET技术 , ASP.NET