Click here to Skip to main content
12,401,682 members (55,868 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
<td>
<span>Passport Type </span>
 </td>
<td colspan="3">
<div class="t-widget t-dropdown t-header" tabindex="10" title="Type of passport carried by the visa applicant"><div class="t-dropdown-wrap t-state-default"><span class="t-input">&nbsp;</span><span class="t-select"><span class="t-icon t-arrow-down">select</span></span></div>&lt;input id="PASSPORType" name="PASSPORType" style="display:none" type="text" value="" /&gt;</div>
<span class="field-validation-valid" data-valmsg-for="PASSPORType" data-valmsg-replace="true"></span>
</td>
 
//<![CDATA[
jQuery(document).ready(function(){
jQuery('#PASSPORType').tDropDownList({data:[{"Text":"","Value":""},{"Text":"Normal","Value":"1"},{"Text":"Diplomatic","Value":"2"},{"Text":"Special","Value":"3"},{"Text":"Hajj Cert","Value":"4"},{"Text":"Travel Cert","Value":"5"}]});
//
</script>
    <script src="/Scripts/jquery-ui-1.8.23/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
</body>
</html>
I want to send values to dropdown list on website which is open in webbrowser control but it can not done by
webBrowser1.Document.GetElementById("VisaKind").InnerText = "Special"
so what will i do ...kindly help me thanks in advance
Posted 18-Feb-13 2:41am
Updated 18-Feb-13 2:43am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,
I have a suggestion. But i don't know that it solve your problem. You should try and see.

I think you may send dropdownlist data as xml with http post. And you shold get this data than set your dropdown list.

look at google for more info like this: sending xml data over http.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

this code
webBrowser1.Document.GetElementById("DateTimePicker").InnerText = "1/1/2013"
is also working for date although it contain same script and jequery but it is not working for dropdownlist.....
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Hi,

here the solution to our problem (I'm working on the same project - Saudi Arabia Visas. My Software was working with old site and now I'm updating. It's really cool.)

Here's some functions

- Import directly the picture from the scanner with the correct size.
- Import data from invitation letter (Name,Nationality, SponsorName, SponsorAddress, SponsorId etc etc) and fill the form automatically.
- Print Visa Form
- Back up in a db all the passport data, so the next visa you don't have to write again (Passport Number, expire, residence, and so on)
- It translates the invitation letter from arabic.

That's just a look, but it does a lot more. Smile | :)

But... let's come back to our problem....I've spent all night long to solve it but in the end it's done Smile | :)

I've decided to inject a function to change all the DropDownList value.

webBrowser1.Document.InvokeScript("eval", New String() {"function ImpostaDrop(Lista,Valore) { var dropDownList = $(Lista).data('tDropDownList'); dropDownList.select(Valore);  }"})

And when I need to change a value here's the VB Code.

WebDocument1.Document.InvokeScript("eval", New String() {"ImpostaDrop('#VisaKind',2)"})

It works great !!! Big Grin | :-D

I'd like to see your software running. Let's keep in touch !!

Alex from Italy
  Permalink  
v2
Comments
shekomero 26-Mar-14 11:49am
   
i am interesting in above code, i have troubles converting this to Vb.net .. any help?
alexpalmieri 9-Nov-14 6:30am
   
Sorry for my late, didn't notice your question.
Hope you've solved meanwhile. The code above is already in Vb.net. What's your problem ? You have a web control named WebBrowser1 loaded with the page. On the eventWebBrowser1_DocumentCompleted you have to use the code

webBrowser1.Document.InvokeScript("eval", New String() {"function ImpostaDrop(Lista,Valore) { var dropDownList = $(Lista).data('tDropDownList'); dropDownList.select(Valore); }"})

This inject a Javascript function on the page that will change the value of DropDown. You can call this function from Vb.Net using this code.

WebDocument1.Document.InvokeScript("eval", New String() {"ImpostaDrop('#VisaKind',2)"})

Where #VisaKind is the name of the dropdown and 2 is the value to set. This is a workaround and it does its job :) If you need more help you can find me at alexpalmieri@gmail.com
Jawad Ahmed Tanoli 12-Nov-14 10:39am
   
Great Work Alex :) actually due to requirement change we used to get data from website using webbrowser by putting a button on webbrowser control when the user fill all form press the button and get all data to store in to database and for further process this project still running good.
which may be like this string visakind= webBrowser1.Document.GetElementById("VisaKind").GetAttribute("value");
alexpalmieri 12-Nov-14 18:45pm
   
Why don't you intercept the Save button on the original web page ? It's the best way. What if your user forget do click on your button and go and save directly the page. You'll loose record. The solution I've adopted save the data when user click on the original button and then send data. A sort of man in the middle. I save all the data in a database and have it for the next time. It takes the first data directly from the invitation letter and the rest from the database. So you can fill the form in 1 minute and without error :)
Hope my job helped you. The VisaKind dropdown and other as you've seen are from telerik and not standard one. So we need to use that workaround to set and read from that dropdown list :)
Let me know if I can help you more. My email is alexpalmieri@gmail.com
Have a good day :)
Alex

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 8 May 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100