Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用C为特定按钮事件调用JavaScript方法#_Javascript_Html_C# 4.0 - Fatal编程技术网

如何使用C为特定按钮事件调用JavaScript方法#

如何使用C为特定按钮事件调用JavaScript方法#,javascript,html,c#-4.0,Javascript,Html,C# 4.0,我的任务是自动验证网页中的内容,网页上有“from airport”和“to airport”文本字段以及SearchFlights按钮。单击SearchFlights按钮后,我会得到搜索结果,我需要将这些结果与预期值进行比较 我正在使用C#with HTML DOM编程来设置文本字段中的文本,并单击SearchFlights按钮 现在,如何捕获事件(例如,documentcompleted)并保存这些结果,以便与预期记录进行比较?我在该web页面中的按钮如下所示: <a tabIndex

我的任务是自动验证网页中的内容,网页上有“from airport”和“to airport”文本字段以及
SearchFlights
按钮。单击
SearchFlights
按钮后,我会得到搜索结果,我需要将这些结果与预期值进行比较

我正在使用C#with HTML DOM编程来设置文本字段中的文本,并单击
SearchFlights
按钮

现在,如何捕获事件(例如,
documentcompleted
)并保存这些结果,以便与预期记录进行比较?我在该web页面中的按钮如下所示:

<a tabIndex="5" class="searchRht" id="searchBtn" onclick="sF();SearchFlights();return false;" href="" />
doc = webBrowser1.Document;
btnElem = doc.GetElementById(streleid);
if (btnElem != null)
{
    btnElem.RaiseEvent("onclick");//click on serach button
    btnElem.RaiseEvent("sF()"); //error comes here
    Application.DoEvents();  // this will load the browser document again
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MultipleFunction.aspx.cs" Inherits="MultiCust_MultipleFunction" %>


<!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>Execute Multiple function with a Button</title>
</head>


<script language="javascript" type="text/javascript">
function ShowMessage()
{
    alert("Hi");
}


</script>


<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
    </form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MultiCust_MultipleFunction : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Button1.Attributes.Add("onClick", "ShowMessage()");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write("Zaq");
    }
}