Zgaorong 2015-12-10 14:49 采纳率: 0%
浏览 1390

button在 本地iis上失效

这是前台的代码

  </div>
        <div>
        <br/><br/><br />
    </div>
        <div id="btn">
            <asp:Button ID="Button1" runat="server"  OnClick="Button1_Click" Text="C灯"    />
            <asp:Button ID="Button2" runat="server"  OnClick="Button2_Click" Text="N灯"   />
            <asp:Button ID="Button3" runat="server"  Text="S灯" OnClick="Button3_Click"  />
        </div>
        <div>
            <br/><br/><br /><br />
        </div>

这是后台代码

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Runtime.InteropServices;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    [DllImport("user32.dll")]
    static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);

    [DllImport("user32.dll",
 CharSet = CharSet.Auto,
 ExactSpelling = true,
 CallingConvention = CallingConvention.Winapi)]
    public static extern short GetKeyState(int keyCode);
    bool ScrollLock = (((ushort)GetKeyState(0x91)) & 0xffff) != 0;

    public static void press(byte i)
    {
        keybd_event(i, 0, 0, 0);
        keybd_event(i, 0, 2, 0);

    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        press(20);
        if (Console.CapsLock)
        {
            TextBox1.Text = "C灯开启";
        }
        else
        {
            TextBox1.Text = "C灯关闭";
        }

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        press(145);
        if (ScrollLock == false)
        {
            TextBox3.Text = "S灯开启";
        }
        else
        {
            TextBox3.Text = "S灯关闭";
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        press(144);
        if (Console.NumberLock)
        {
            TextBox2.Text = "N灯开启";
        }
        else
        {
            TextBox2.Text = "N灯关闭";
        }
    }


}


在vs中使用iis experss调试时button是正常执行的,但是换成本地iis或者发布到iis上就失效了,页面可以打开但是并不执行。

  • 写回答

2条回答 默认 最新

  • IT_pclstar 2015-12-10 14:55
    关注

    端口号对么?要不关闭防火墙试试看

    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?