我正在开发一个带有两个DropDown List的asp.net页面,从数据库中的同一个表中填充值,用户需要选择帐户名,我希望第二个DropDown List自动填充它自己的值(Acount Code) )根据第一个下拉列表选择共享相同的帐户名称。这是我的示例代码......
\Browser Tests>protractor edge_conf
[13:32:48] I/launcher - Running 1 instances of WebDriver
[13:32:48] I/hosted - Using the selenium server at http://localhost:17556
[13:32:48] E/launcher - Unknown error
[13:32:48] E/launcher - WebDriverError: Unknown error
at WebDriverError (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5)
at Object.checkLegacyResponse (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15)
at parseHttpResponse (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:777:24)
at createDriver (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:167:33)
at Builder.build (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:632:14)
at Hosted.getNewDriver (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.ts:60:29)
at Runner.createBrowser (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:225:39)
at q.then.then (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:391:27)
at _fulfilled (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
[13:32:48] E/launcher - Process exited with error code 199
我的C#代码如下..
<span class="label">
<asp:Label ID="Label2" runat="server" Text="Account Name"</asp:Label>
</span>
<asp:DropDownList ID="name" runat="server"></asp:DropDownList><br />
<span class="label">
<asp:Label ID="Label3" runat="server" Text="Account Code"></asp:Label>
</span>
<asp:DropDownList ID="code" runat="server"></asp:DropDownList>
在我的情况下,如果我更改帐户名称的值,帐户代码不会自动更改。我怎么能让这种情况发生..?谢谢
答案 0 :(得分:0)
为了满足您的要求,您必须在第一个下拉列表中添加两个属性(1)&#34; AutoPostBack&#34;和(2)&#34; OnSelectedIndexChanged&#34;。
1)当你在下拉列表中选择一个项目时,Autopostback将导致回发。
2)OnSelectedIndexChanged是您必须编码以填充第二个下拉列表的事件。
<asp:DropDownList ID="name" runat="server" AutoPostBack="true" OnSelectedIndexChanged="name_SelectedIndexChanged"></asp:DropDownList>