不要通过点击html控件来运行我的脚本 [英] Don’t be run my script by click html control

查看:80
本文介绍了不要通过点击html控件来运行我的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不要通过单击html控件来运行我的脚本
HI''
在vs2010中,我在页面上放置了html控件(bottun).并为其定义了javascript函数.并在< input….>
中设置必要的内容. 1-在设计中,每当我单击bottun时,都会创建新功能
2-在设计中,每双击bottun,就会将onload ="func_name()"添加到In< input…>的末尾.因此,在< input ..>
末尾将写入许多onloald. 3-当我删除不必要的onload和额外功能的主体,并运行该站点并单击bottun时,它将不起作用.

Don’t be run my script by click html control
HI''
In vs2010 I put a html control (bottun) on page . and defined a function of javascript for it. And set the necessary things in <input ….>
1- In design whenever I click the bottun the new function will create
2- In design , by every double click on bottun, the onload="func_name()" will added to end of In <input …> therefor there will be write many onloald at end of <input ..>
3- When I delete unnecessary onload and body of extra function, and run the site and click the bottun , it willn''t work.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="script4.aspx.cs" Inherits="WebApplication1.script4" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">


        function reset_onclick() {
            //document.write("JJJJJJJJJJJJJJJ");
            document.forms[0].reset();
            return false;
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        &nbsp;<input id="Text1" type="text" value="TEST FOR CLEAR" />&nbsp;&nbsp;&nbsp;&nbsp;
        <input id="Checkbox1" checked="checked" type="checkbox" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input id="Radio1" checked="checked" type="radio" /><br />
        <br />

        <input id="reset" type="button" value="reset" onclick="return reset_onclick()" />
        <br />
        <asp:Button ID="MyResetButton" runat="server" onclick="Button1_Click"

            Text="MyResetButton" />

     </div>
    </form>
</body>
</html>

推荐答案

亲爱的朋友,

我稍微改变了你的代码.现在工作正常.复制粘贴此代码,它将起作用

Dear Friend,

I changed you code little bit. Its working fine now. copy paste this code , it will work

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="script4.aspx.cs" Inherits="WebApplication1.script4" %>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>

    <script language="JavaScript">
        function resetForm() {
            document.getElementById("userForm").reset();
        }
    </script>

    <form id="userForm" runat="server">
    <input id="Text1" type="text" value="TEST FOR CLEAR" />
    <input id="Checkbox1" checked="checked" type="checkbox" />
    <input id="Radio1" checked="checked" type="radio" />
    <br />
    <input type="button" value="Reset all fields" onclick="resetForm()" />
    <br />
    <asp:Button ID="MyResetButton" runat="server" OnClick="Button1_Click" Text="MyResetButton" />
    </form>
</body>
</html>





问候,
Sabindas





Regards,
Sabindas


这篇关于不要通过点击html控件来运行我的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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