动态组合框不在.NET VB webbrowser中触发。 [英] Dynamic combobox not triggered in .NET VB webbrowser.

查看:83
本文介绍了动态组合框不在.NET VB webbrowser中触发。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.net表单,它应该导航到.netwebbrowser中的特定网页,一旦加载它应该选择一个名为status的组合框并选择待定选项,它应该触发并显示另一个名为pending cause的组合框,其中包含待处理原因列表和从那里它应该根据一些标准选择2和/或第三选项。该网页是我的组织内部工具,这个项目已经在excel VBA宏中运行得很好,但我现在必须将它迁移到.net表单的应用程序。我在制作第一个组合框触发器时遇到了麻烦。我可以看到第一个组合框,其中下拉列表从已分配更改为待定。然而,第二个组合框没有出现。在excel VBA中,这种自动化使用铬和硒完成。但是在.net VB webbrowser中我认为一些内部触发机制不起作用。我将在下面发布html和jquery函数。





 <   table     id   =  left_nav >  
< tbody >
< tr >
< td colspan = 2 >
< 标签 > 状态 < / label >
< span id = editNavMenuLink

class = small_link > 点击编辑< / span >
< br / >

< div class = dynamic_select_holder >
< select < span class =code-attribute> name = status id = status >
< 选项 value =



< span class =code-attribute>
> < / option >
< 选项 = 已分配



> 已分配的< / option >
< 选项 value = 研究 < span class =code-attribute>



< span class =code-attribute>
> 研究< / option >
< 选项 < span class =code-attribute> value = 正在进行中



> 正在进行中< / option >
< 选项 value = 待定

< span class =code-attribute> < span class =code-attribute> 已选择 = 已选中

< span class =code-attribute> > 待定< / option >
< 选项 < span class =code-attribute> value = 已解决



< span class =code-attribute> > 已解决< / option >
< / select >
< span > 待定< / span >
< / div >
< / td >
< / tr >
< tr id = pending_reason_row style = < span class =code-关键字> >
< td colspan = 2 >
< label id = pending_reason_label > 待定
原因< / label > < br / >
< div class = dynamic_select_holder >
< 选择 name = pending_reason

< span class =code-attribute> id = pending_reason >
< 选项 = / > < / option >
< 选项 = 目录推送

< span class =code-attribute> 已选择 = 选中 / > 目录按< / option >
< / select >
< span > 目录推送< / span >
< / div >
< / td >





<前lang =JavaScript> 功能(){
if this .value == 待定){
$(' 。#pending_reason_row')表示();
} else {
$(' #pending_reason_row')隐藏();
}

if this .value == 已解决 || .value == 已关闭){
$('' #time_spent_row')。show();
} else {
$(' #time_spent_row')隐藏();
}


if this .value == 已解决 || .value == 已关闭){
$(' #closure_code_row')。show();
$(' #root_cause_row')。show();
$(' #root_cause_details_row')。show();
$(' #resolution_row')。show();
} else if this .value == 待定){
$(' #root_cause_row')。show();
$(' #root_cause_details_row')。show();
} else {
$(' #closure_code_row')隐藏();
$(' #root_cause_row')。hide();
$(' #root_cause_details_row')。hide();
$(' #resolution_row')。hide();
}
}





i看到我以某种方式必须触发此功能,以便动态组合框将改变。



我尝试了什么:



我的vb代码是这个



  .WebBrowser1.Document.GetElementById(  status)。SetAttribute(  selectedIndex 4 
Me .WebBrowser1。 Document.GetElementById( pending_reason)。SetAttribute( selectedIndex 2



第一个代码将状态从已分配更改为挂起。但是第二个组合框没有出现

解决方案

' 。#pending_reason_row')表示();
} else {


' #pending_reason_row')隐藏();
}

if this .value == 已解决 || .value == 已关闭){


' #time_spent_row')。show();
} 其他 {


I have a .net form which should navigate to a particular webpage in .netwebbrowser and once loaded it should select a combobox called status and select option pending, it should trigger and show another combobox called pending reason with list of pending reason and from there it should select 2 and or third option based on some criteria. The webpage is my organisations internal tool, and this project is already running perfectly fine in excel VBA macro but I now have to migrate it to .net form kinda application. I have trouble in making the first combobox trigger the second one. I can see that the first combobox where the dropdown changes from assigned to pending. However the second combobox doesn't appear. In excel VBA this automation was done using chrome and selenium. However in .net VB webbrowser I think some internal trigger mechanism doesn't work. I'll postmy html and jquery function below.


<table id="left_nav">
                           <tbody>
                        <tr>
                            <td colspan="2">
                                <label>Status</label>
                                <span id="editNavMenuLink" 

                         class="small_link">Click to edit</span>
                                <br/>
                                <div class="dynamic_select_holder">
                                  <select name="status" id="status">
                                      <option value=""



                                      ></option>
                                      <option value="Assigned"



                                      >Assigned</option>
                                      <option value="Researching"



                                      >Researching</option>
                                      <option value="Work In Progress"



                                      >Work In Progress</option>
                                      <option value="Pending"

                                           selected="selected"

                                      >Pending</option>
                                      <option value="Resolved"



                                      >Resolved</option>
                                  </select>
                                  <span>Pending</span>
                                </div>
                            </td>
                        </tr>
                        <tr id="pending_reason_row" style="">
                            <td colspan="2">
                                <label id="pending_reason_label">Pending 
                                     Reason</label><br/>
                                <div class="dynamic_select_holder">
                                  <select name="pending_reason" 

                                   id="pending_reason">
                                    <option value=""/></option>
                                    <option value="Catalog Push" 

                           selected="selected"/>Catalog Push</option>
                                  </select>
                                  <span>Catalog Push</span>
                                </div>
                            </td>



function() {
             if (this.value == "Pending") {
              $('#pending_reason_row').show();
                  } else {
              $('#pending_reason_row').hide();
                          }

             if (this.value == "Resolved" || this.value == "Closed") {
              $('#time_spent_row').show();
                } else {
             $('#time_spent_row').hide();
                 }


             if (this.value == "Resolved" || this.value == "Closed") {
                $('#closure_code_row').show();
              $('#root_cause_row').show();
                $('#root_cause_details_row').show();
                  $('#resolution_row').show();
              } else if (this.value == "Pending") {
                $('#root_cause_row').show();
                      $('#root_cause_details_row').show();
                         } else {
                    $('#closure_code_row').hide();
                        $('#root_cause_row').hide();
                     $('#root_cause_details_row').hide();
                      $('#resolution_row').hide();
                           }
                             }



i see that i somehow have to trigger this function so that the dynamic combobox will change.

What I have tried:

my vb code is this

Me.WebBrowser1.Document.GetElementById("status").SetAttribute("selectedIndex", 4)
Me.WebBrowser1.Document.GetElementById("pending_reason").SetAttribute("selectedIndex", 2)


The first code changes the status from assigned to pending. However the second combobox does not appears

解决方案

('#pending_reason_row').show(); } else {


('#pending_reason_row').hide(); } if (this.value == "Resolved" || this.value == "Closed") {


('#time_spent_row').show(); } else {


这篇关于动态组合框不在.NET VB webbrowser中触发。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆