1

Like the statement,

string value = document.forms["sap.client.SsrClient.form"].elements["sapwdssr..requestCounter"].value;

in javascript, is there a corresponding statement to get the value of a particular input element within a particular form in C#?

I can do so by using HTMLDocument and mshtml interface. But that is a rather cumbersome process so if any direct method or property exists it would be great.

Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
arunondeck
  • 368
  • 6
  • 16

1 Answers1

0

I assume you are asking to parse HTML, rather than attempting to do some form of runtime manipulation of a rendered web page, correct?

If that's the case, I highly suggest you look into the HTML Agility Pack, which we have used very successfully to parse HTML as if it were XML. You could do your stuff with a simple XPath query.

Randolpho
  • 55,384
  • 17
  • 145
  • 179
  • No I don't need to parse the HTML. Rather I need to use that particular value of the input element on the page. – arunondeck Jul 19 '11 at 12:44
  • @arunondeck: Do you have an embedded browser in your application, or is this executing in, say, Chrome? – Randolpho Jul 19 '11 at 12:46
  • Actually its an addon for IE. I'm using mshtml to get the HTML source. – arunondeck Jul 19 '11 at 12:55
  • The HTML source? So you're not actually hoping to walk the DOM? Sounds like HTML Agility Pack may be what you need after all. – Randolpho Jul 19 '11 at 13:55
  • What would I need to do in order to walk the DOM? – arunondeck Jul 20 '11 at 09:53
  • @arunondeck: if you're doing it in the context of an IE addon, then you absolutely have to use [MSHTML](http://msdn.microsoft.com/en-us/library/aa741317(VS.85).aspx). TreeWalker and a complex loop should do the trick. – Randolpho Jul 20 '11 at 12:22