Pergunta

Hey I'm try to make a Windows Phone app that logs people in to a webpage, but I'm having trouble getting the app to post the log-in info to the webbrowser.

on the desktop I would have used

           HTMLInputElement nameBox = (HTMLInputElement) myDoc.all.item("name", 0);
           HTMLInputElement passBox = (HTMLInputElement) myDoc.all.item("pass", 0);

       nameBox.value = "textBox1.text";
           passBox.value = "textBox2.text;   

but the HTMLInputElemet don't exist in Windows Phone.

I also tried using webBrowser1.document but that don't work either on Windows Phone. It is a log-in using a form and not a query string.

The server side code look like this:

    <div class="form-item textfield edit-name">
      <div class="label">
      <label >E-mail-adresse</label>
    </div>
    <input type="text" maxlength="60" placeholder="" name="name" id="edit-name" size="60" value="" class="form-text required" />  </div>
<div class="form-item password edit-pass">
      <div class="label">
      <label >Adgangskode</label>
    </div>
    <input type="password" name="pass" id="edit-pass"  maxlength="128"  size="60"  class="form-text required" />  </div>
<input type="hidden" name="form_build_id" id="form-b6cb750ff3a79c34d408df98d730a39e" value="form-b6cb750ff3a79c34d408df98d730a39e"  />
<input type="hidden" name="form_id" id="edit-user-login" value="user_login"  />
<div class="form-actions"><input type="submit" name="op" id="edit-submit" value="Log ind"  class="form-submit" />

It is easy in the desktop but I just cant figure out how to do this on the Phone, hope some one can help.

Foi útil?

Solução

One way to access the fields is using Javascript, thanks to the InvokeScript method:

webBrowser1.InvokeScript("eval", string.Format("document.getElementsByName('name')[0].value='{0}'", "PutTheLoginHere"));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top