在 WPF HTML 数据绑定时间异常未知名称。(HRESULT 异常:0x80020006(DISP_E_UNKNOWNNAME))
In WPF HTML data bind time exception Unknown Name.(Exception from HRESULT: 0x80020006(DISP_E_UNKNOWNNAME) )
我正在将 WPF 与 .Net 结合使用。在应用程序中,我在网页上携带 HTML 内容,然后生成了数据绑定时间异常。而在调试时没有产生任何异常。
这是我的代码 -
public ReopemForm(string policyno)
{
InitializeComponent();
InitailSetup();
pghReopenForm.lblPageHeader.Content = "Agency Add Edit";
pghReopenForm.lblPageHeader.Visibility = Visibility.Visible;
pghReopenForm.imgPanel.Visibility = Visibility.Hidden;
PolicyNo = policyno;
}
private void InitailSetup()
{
this.Height = System.Windows.SystemParameters.PrimaryScreenHeight - 130;
mainGrid.MaxHeight = Height - 50;
pghReopenForm.Close_Click += btnClose_Click;
pghReopenForm.Minimize_Clik += btnMinimize_Click;
pghReopenForm.PageTitle = "Policy Add";
string curDir = Directory.GetCurrentDirectory();
string countryPath = AILClasses.AILGlobal.CurrentUser.CountryId;
string ProvincePath = AILClasses.AILGlobal.CurrentUser.ProvinceId;
string htmlPath = String.Format("file:///{0}/Forms/{1}/{2}/ReopenForm.html", curDir, countryPath, ProvincePath);
var str = new Uri(htmlPath);
myWebBrowser.Navigate(str);
myWebBrowser.Width = frmCustomerAddEdit.Width - 10;
myWebBrowser.LoadCompleted += MyWebBrowser_LoadCompleted;
}
private void MyWebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
try
{
//string functionUsername = string.Format(@"document.getElementById('txtappNumber').value = "+ PolicyNo + ";");
// var xyz = myWebBrowser.InvokeScript("eval", new string[] { functionUsername });
string[] txtappnum = { "txtappNumber", PolicyNo };
this.myWebBrowser.InvokeScript("SetKeyValue", txtappnum);
string[] lblAppnum = { "lblappNumber", PolicyNo };
this.myWebBrowser.InvokeScript("SetKeyValuehtml", lblAppnum);
string[] dateargs = { "txtdate", DateTime.Now.ToShortDateString() };
this.myWebBrowser.InvokeScript("SetKeyValue", dateargs);
string[] datelbl = { "lbldate", DateTime.Now.ToShortDateString() };
this.myWebBrowser.InvokeScript("SetKeyValuehtml", datelbl);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
请帮我解决这个问题。
谢谢
你可以试试这个-
<!-- saved from url=(0016)https://localhost -->
我正在将 WPF 与 .Net 结合使用。在应用程序中,我在网页上携带 HTML 内容,然后生成了数据绑定时间异常。而在调试时没有产生任何异常。 这是我的代码 -
public ReopemForm(string policyno)
{
InitializeComponent();
InitailSetup();
pghReopenForm.lblPageHeader.Content = "Agency Add Edit";
pghReopenForm.lblPageHeader.Visibility = Visibility.Visible;
pghReopenForm.imgPanel.Visibility = Visibility.Hidden;
PolicyNo = policyno;
}
private void InitailSetup()
{
this.Height = System.Windows.SystemParameters.PrimaryScreenHeight - 130;
mainGrid.MaxHeight = Height - 50;
pghReopenForm.Close_Click += btnClose_Click;
pghReopenForm.Minimize_Clik += btnMinimize_Click;
pghReopenForm.PageTitle = "Policy Add";
string curDir = Directory.GetCurrentDirectory();
string countryPath = AILClasses.AILGlobal.CurrentUser.CountryId;
string ProvincePath = AILClasses.AILGlobal.CurrentUser.ProvinceId;
string htmlPath = String.Format("file:///{0}/Forms/{1}/{2}/ReopenForm.html", curDir, countryPath, ProvincePath);
var str = new Uri(htmlPath);
myWebBrowser.Navigate(str);
myWebBrowser.Width = frmCustomerAddEdit.Width - 10;
myWebBrowser.LoadCompleted += MyWebBrowser_LoadCompleted;
}
private void MyWebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
try
{
//string functionUsername = string.Format(@"document.getElementById('txtappNumber').value = "+ PolicyNo + ";");
// var xyz = myWebBrowser.InvokeScript("eval", new string[] { functionUsername });
string[] txtappnum = { "txtappNumber", PolicyNo };
this.myWebBrowser.InvokeScript("SetKeyValue", txtappnum);
string[] lblAppnum = { "lblappNumber", PolicyNo };
this.myWebBrowser.InvokeScript("SetKeyValuehtml", lblAppnum);
string[] dateargs = { "txtdate", DateTime.Now.ToShortDateString() };
this.myWebBrowser.InvokeScript("SetKeyValue", dateargs);
string[] datelbl = { "lbldate", DateTime.Now.ToShortDateString() };
this.myWebBrowser.InvokeScript("SetKeyValuehtml", datelbl);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
请帮我解决这个问题。 谢谢
你可以试试这个-
<!-- saved from url=(0016)https://localhost -->