Boa tarde, tenho um código HTML, mas que terei que executar no windform, segue o código:
string sXML = "<?xml version=\"1.0\"?> <CONTRATOS>";
sXML += "<CONTRATO>";
sXML += "<CodCliente>3338491</CodCliente> ";
sXML += "<UserID>3338492</UserID>";
sXML += "<NomeCliente>teste01</NomeCliente>";
sXML += "</CONTRATOS>";
webBrowser1.DocumentText =
"<html>" +
"<head>" +
"<script type=\"text/javascript\">" +
"window.onload = function() {document.getElementById('form1').submit()}" +
"</script>" +
"</head>" +
"<body >" +
"<form id=\"form1\" runat=\"server\" action=\"http://minhaURL\" method=\"post\" enctype=\"multipart/form-data\"> <br/>" +
"<input type=\"text\" name=\"method\" value=\"IncluirItemContrato\" /><br />" +
"<input id=\"myfiles\" name=\"xml\" type=\"file\" value=\"\" /><br/>" +
"<input type=\"submit\" name=\"enviar\" value=\"Enviar\" /> <br/>" +
"</form><br/>" +
"</body><br/>" +
"</html>";
webBrowser1.Navigating += new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
System.Windows.Forms.HtmlDocument document = this.webBrowser1.Document;
if (document != null && document.All["userName"] != null && String.IsNullOrEmpty(document.All["userName"].GetAttribute("value")))
{
e.Cancel = true;
System.Windows.Forms.MessageBox.Show(
"You must enter your name before you can navigate to " +
e.Url.ToString());
}
}
O que eu preciso, carregar no campo input type="file" carregar o meu arquivo xml, tentei passar como string colocando uma variável mas não deu, alguém pode me ajudar????