zoukankan      html  css  js  c++  java
  • JavaScript调用服务器事件

    在aspx文件中找到Form1标签,在其后增加如下js脚本:
            <input type="hidden" name="__EVENTTARGET"> <input type="hidden" name="__EVENTARGUMENT">
       <script language="javascript" type="text/javascript">
        <!--
        function __doPostBack(eventTarget, eventArgument) {
        var theform;
        if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
        theform = document.Form1;
        }
        else {
        theform = document.forms["Form1"];
        }
        theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
        theform.__EVENTARGUMENT.value = eventArgument;
        theform.submit();
        }
        // -->
       </script>

    2、 然后javascript的函数中使用__doPostBack('Button1','')就可以调用指定服务器按钮的事件了,目前测试了调用 Button的Click事件没有任何问题,不过即使Button的Visible="False"是,事件也是可以被触发的,所以如果需要调用别的服务 器函数或者事件,可以在界面上放一个隐藏的Button控件,然后在它的Click事件中调用别的函数即可。
  • 相关阅读:
    nyist 541最强DE 战斗力
    nyist 231 Apple Tree
    nyist 543 遥 控 器
    nyist 233 Sort it
    nyist 517 最小公倍数
    hdu 1sting
    nyist A+B Problem IV
    nyist 522 Interval
    nyist 117 求逆序数
    nyist 600 花儿朵朵
  • 原文地址:https://www.cnblogs.com/ruanbl/p/776815.html
Copyright © 2011-2022 走看看