views:

28

answers:

1

I'm using ObjectForScripting property to interact with web page inside WebBrowser control and everything works fine except I can't figure out how to pass array of strings back to C#

HTML code

<input type="submit" onclick="window.external.save(Array('test', 'test2'))" />

Form

// Returns System.__ComObject
public void Save(object parameters)
{
}

// Throws an exception
public void Save(object[] parameters)
{
}

// Also throws an exception
public void Save(string[] parameters)
{
}
A: 

Rather than fight it; maybe approach the problem from another angle... could you (instead, either of):

  • delimit the data (with Array.join) and pass a single string, and split it (string.Split) in the C#
  • call Save multiple times, accepting a single string each time (Save(string s)), then call a final method to actually commit the changes
Marc Gravell
I could. I suspect you are suggesting that because marshaling objects from JS to .NET is tricky and doesn't worth it if workaround is possible. Are you?
Sergej Andrejev
@Sergej pretty much, yes. It doesn't want to work the way you are showing... so don't do that ;p
Marc Gravell