1

i hope to data in table to winform datagridview.

here's the working code

<body>
<form name="form1" method="post" action="CallOpen.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/w~~~~==" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}

other aspx

<iframe frameborder="0" id="ifrmmain" class="mainiframe" scrolling="auto" style="display: inline;" src="/Category/Service/Call/CallOpen.aspx">
#document
<html ~~~>
<head> ~~~ />
<body> 
<form name="form1" meothd="post" action="~~~" id="form1">
<div id="content">
</div>
</form>
</iframe>

i just show that iframe data in my winform.

stop-cran
  • 4,229
  • 2
  • 30
  • 47
  • This will give you the JSON response object. What else do you need? – praty Aug 22 '17 at 06:21
  • @praty, that gives you only the string, but it not in json format. – Mihai Alexandru-Ionut Aug 22 '17 at 06:26
  • i want execute javascript in c# winfrom if i pressed the button – Geun-Yeol Lee Aug 22 '17 at 06:47
  • Do you have a `webbrowser` running in your `winform` application where you are loading a page with a javascript? – praty Aug 22 '17 at 07:01
  • Please check if this is what you are looking for: https://stackoverflow.com/questions/5731224/calling-javascript-function-from-codebehind – praty Aug 22 '17 at 07:02
  • Make no sense you try to run JavaScript in WindowsForms App? If was Webforms or MVC OK.. you can use functions like Page.ClientScript.RegisterStartupScript to do the trick. (but in WEB). Or you can explain more about your scenario.. – Thiago Loureiro Aug 22 '17 at 07:15
  • What exactly are you trying to do? Your application is WinForms right? You want to retrieve an value? From where? Why don't you create an WebAPI or WebService ? Then you can connect via WindowsForms Application and get the values correctly. – Thiago Loureiro Aug 22 '17 at 07:17
  • @ThiagoLoureiro in my Winforms, execute javascript(web path) and gather data and showing my datagrid – Geun-Yeol Lee Aug 22 '17 at 07:19
  • can you type the webpath that you have here? – Thiago Loureiro Aug 22 '17 at 07:26

1 Answers1

0

The HTML Agility Pack can load and parse the file for you, no need for messy streams and responses:

http://html-agility-pack.net/?z=codeplex

Example:

c# code:

  private void button1_Click(object sender, EventArgs e)
    {
        HtmlWeb web = new HtmlWeb();
        var doc = web.Load("http://localhost/site.html");
        HtmlNode rateNode = doc.DocumentNode.SelectSingleNode("//iframe[@id='test']");
        string rate = rateNode.InnerText;
    }

HTML File with the iframe:

<!DOCTYPE html>
<html>
<body>

<iframe id="test" src="https://www.w3schools.com">

</iframe>

</body>
</html>
Thiago Loureiro
  • 1,041
  • 13
  • 24