Darth Vader 0 Junior Poster in Training

Hello,

I use the webkitbrowser which is simular to the webbrowser.
Now on a website, I want to programatically insert a string into a textBox.

This I have succeeded to do like this:

webKitBrowser1.Document.GetElementById("txtbox1").SetAttribute("value", "hello");

After this I will need to programatically click a button that will check that "hello" is correct. I have succeeded to click the button like this:

    webKitBrowser1.Document.InvokeScriptMethod("execFunction", new object[] {  });

Now comes the problem. When "execFunction" is activated which is a <a></a> tag in HTML, I get the message that the "hello" string is not correct.
Now I know why that is the problem. The textBox1 control has an event that detects keydown like this: onkeydown="javaScript: afSI(event);"
So what is missing when just set the string "hello" is that there is a javascript event "afSI" that has registrated that the "hello" text was entered manually where the "onkeydown" fires.

Below are all the code including javascript code that detects "onkeydown": "Number($F) == 13"
So my question would be, instead of putting the string "hello" like above. Can we simulate "onkeydown" that sends along the string "hello" to the textBox with the KeyCode == 13 ?

            afSI($N)
            {
                var $F = document.all?event.keyCode:$N.which?$N.which:$N.keyCode?$N.keyCode:$J.charcode;
                var $T = document.frmMain.txtbox1;
                if(typeof $T!=='undefined')
                {
                    if($T.value.length > 0 && Number($F) == 13)
                    {
                        execFunction();
                    }
                }
            };

//This is the textBox
<input type="text" tabindex="1" class="ibtxt" name="txtbox1" id="txtbox1" maxlength="20" onfocus="javaScript: focusFunc(this);" style="display:inline;visibility:visible;" value="">
<input type="text" tabindex="2" class="ibtxt" name="txtbox1" id="txtbox1" maxlength="20" onkeydown="javaScript: afSI(event);" style="display:none;visibility:hidden;">


//This is the button
<a class="iomcc" href="#" tabindex="1" id="execButton" onclick="javascript:execFunction(); return false;"></a>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.