为什么我不能使用“Invokemember(“click”)”以编程方式单击我的按钮?

发布于 2024-11-10 15:58:11 字数 1546 浏览 4 评论 0原文

我正在尝试通过 WebBrowserControl 从应用程序中的网站获取数据。我可以成功登录,但当我以编程方式调用 btnsearch.Invokemember("click") 时,我收到 JavaScript 错误。如果我以交互方式单击 WebBrowserControl 上的按钮,我不会收到任何错误,并且一切正常。

在 aspx 页面中,我有一个用于调用 Ajax 面板的 JavaScript 函数:

<script type="text/javascript">
/*<![CDATA[*/   
window["ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel"] = new RadAjaxPanelNamespace.RadAjaxPanel({ClientID:"ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel",EnableOutsideScripts:false,EnablePageHeadUpdate:true,Url:"/app/ModuleCustomer/ViewAVITransactions.aspx",LoadingPanelID:"ctl00_WorkSpace_ctlCustAVIHistory_LoadingPanel1",ActiveElementID:"",ClientEvents:{OnRequestStart:"",OnRequestSent:"",OnResponseReceived:"",OnResponseEnd:""},FormID:"aspnetForm",UniqueID:"ctl00$WorkSpace$ctlCustAVIHistory$ajxResultPanel"});/*]]>*/
</script>

它生成一个 UniqueID。如果我们通过代码单击btnsearch,则此唯一 ID 为空。

function onClickButton(rName) 
{
    if(validateData())
    {     
        document.getElementById("ctl00_WorkSpace_ctlCustAVIHistory_hdnReset").value = "0";    
        ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel.AjaxRequest("NewSearch"); ///these caling down function       
    }      
}

RadAjaxPanelNamespace.RadAjaxPanel.prototype.AjaxRequest = function (eventArgument) {       
    this.AjaxRequestWithTarget(this.UniqueID, eventArgument);//this.UniqueID giving null from program click mouse click it is giving correct id 
};

知道为什么会发生这种情况吗?

I am trying to fetch data from a website in my application through a WebBrowserControl. I can successfully log in, but when I call btnsearch.Invokemember("click") programmatically I receive a JavaScript error. If I click the button interactively on the WebBrowserControl I receive no error and everything works fine.

In the aspx page I have one JavaScript function for calling an Ajax Panel:

<script type="text/javascript">
/*<![CDATA[*/   
window["ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel"] = new RadAjaxPanelNamespace.RadAjaxPanel({ClientID:"ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel",EnableOutsideScripts:false,EnablePageHeadUpdate:true,Url:"/app/ModuleCustomer/ViewAVITransactions.aspx",LoadingPanelID:"ctl00_WorkSpace_ctlCustAVIHistory_LoadingPanel1",ActiveElementID:"",ClientEvents:{OnRequestStart:"",OnRequestSent:"",OnResponseReceived:"",OnResponseEnd:""},FormID:"aspnetForm",UniqueID:"ctl00$WorkSpace$ctlCustAVIHistory$ajxResultPanel"});/*]]>*/
</script>

It produces a UniqueID. If we click on btnsearch through code this unique id is null.

function onClickButton(rName) 
{
    if(validateData())
    {     
        document.getElementById("ctl00_WorkSpace_ctlCustAVIHistory_hdnReset").value = "0";    
        ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel.AjaxRequest("NewSearch"); ///these caling down function       
    }      
}

RadAjaxPanelNamespace.RadAjaxPanel.prototype.AjaxRequest = function (eventArgument) {       
    this.AjaxRequestWithTarget(this.UniqueID, eventArgument);//this.UniqueID giving null from program click mouse click it is giving correct id 
};

Any idea why this happens?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

歌入人心 2024-11-17 15:58:11
    private const string STR_Field_userid = "field_userid";
    private const string STR_Field_password = "field_password";
    private const string STR_Submit = "submit";            

        document.GetElementById(STR_Field_userid).InnerText = UserId;
        document.GetElementById(STR_Field_password).InnerText = Password;
        document.Forms[0].InvokeMember(STR_Submit);
    private const string STR_Field_userid = "field_userid";
    private const string STR_Field_password = "field_password";
    private const string STR_Submit = "submit";            

        document.GetElementById(STR_Field_userid).InnerText = UserId;
        document.GetElementById(STR_Field_password).InnerText = Password;
        document.Forms[0].InvokeMember(STR_Submit);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文