开发者

Why cant I use `Invokemember("click")` to click my button programatically?

I am trying to f开发者_如何学JAVAetch 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?


    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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜