1

I have a web browser control in a C# app that upon page completed it inserts a script into the document.

The script is to change a combo box value for automation.

The thing is when the script is executed the normal behavour of the original site is not working. It is meant to load some results via AJAX.

Though if I click and change the combo box using the mouse it does work.

The script is like this

$("#orderBySelect").val('prfs');  $("#orderBySelect").click();

Though I have tried the change event also as well as a combination of other events including the click event on the selected option.

Any idea why this would be?

1 Answer 1

1

If "orderBySelect" is an ASP.NET UserControl (i.e. it has runat="server"), ASP.NET will silently modify that ID (by prefixing a string to it) when it flushes the HTML to your browser.

Generally I work around that by using this instead:

$('[id$="orderBySelect"]')

which basically says "the element with an ID that ends with "orderBySelect".

Sign up to request clarification or add additional context in comments.

2 Comments

it's not. If I put an alert call in the click method it gets called. Also I can see the value of the select box change. It just doesn't load the search results like it should
then that just means that your .click() above works, and we'll need to see some more code to get this problem rolling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.