问题描述
我试图从一个网站的数据在我的应用程序通过 WebBrowserControl
取。我可以成功登录,但是当我打电话 btnsearch.Invokemember(点击)
编程我收到一个JavaScript错误。如果我按一下按钮交互方式上的 WebBrowserControl
我收到任何错误,一切工作正常。
在aspx页面我有一个JavaScript函数调用一个Ajax面板:
<脚本类型=文/ JavaScript的>
/ *<![CDATA [* /
窗口[ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel] =新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。如果我们通过code点击 btnsearch
这种独特的id为null。
函数onClickButton(RNAME)
{
如果(是validateData())
{
。的document.getElementById(ctl00_WorkSpace_ctlCustAVIHistory_hdnReset)值=0;
ctl00_WorkSpace_ctlCustAVIHistory_ajxResultPanel.AjaxRequest(NewSearch); ///这些caling关闭功能
}
}RadAjaxPanelNamespace.RadAjaxPanel.prototype.AjaxRequest =功能(eventArgument){
this.AjaxRequestWithTarget(this.UniqueID,eventArgument); // this.UniqueID给从方案点击鼠标点击空被赋予正确ID
};
任何想法,为什么出现这种情况?
私人常量字符串STR_Field_userid =field_userid;
私人常量字符串STR_Field_password =field_password;
私人常量字符串STR_Submit =提交; 的document.getElementById(STR_Field_userid).InnerText =用户ID;
的document.getElementById(STR_Field_password).InnerText =密码;
document.Forms [0] .InvokeMember(STR_Submit);
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?
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);
这篇关于为什么不能我使用`Invokemember(QUOT;按一下[)`点击我的按钮编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!