Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以从web到应用程序获取javascript数据_Javascript_C#_Asp.net_.net - Fatal编程技术网

是否可以从web到应用程序获取javascript数据

是否可以从web到应用程序获取javascript数据,javascript,c#,asp.net,.net,Javascript,C#,Asp.net,.net,我需要从网站(例如facebook)到我的.NET应用程序中获取innerHTML字符串列表。 是否有方法将以下函数的结果输入到我的应用程序中(我会将此数据放入列表): var data=new Array(); 对于(i=0;i,以下是一个示例: 请参见隐藏字段数组存储 客户端: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></titl

我需要从网站(例如facebook)到我的.NET应用程序中获取innerHTML字符串列表。
是否有方法将以下函数的结果输入到我的应用程序中(我会将此数据放入列表):

var data=new Array();
对于(i=0;i,以下是一个示例:

请参见隐藏字段数组存储

客户端:

 <html xmlns="http://www.w3.org/1999/xhtml">
   <head runat="server">
    <title></title>
     <script type="text/javascript">
         var array_store;
         window.onload = function () {
             array_store = document.getElementById("array_store");
             document.getElementById("array_disp").innerHTML = array_store.value;
         };
         function UpdateArray() {
             var arr;
             if (array_store.value == "") {
                 arr = new Array();
             } else {
                 arr = array_store.value.split(",");
             }
             arr.push((arr.length + 1).toString());
             array_store.value = arr.join(",");
         };
    </script>
  </head>
   <body>
    <form id="form1" runat="server">
    <span id="array_disp"></span>
    <br />
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="UpdateArray()" />
    <input type="hidden" id="array_store" name = "ArrayStore" value = '<%=this.ArrayStore %>' />
    </form>
  </body>
  </html>

查看有关将表单数据发布到.net MVC控制器的文档。这将为您提供大部分方法。然后查看如何在更新这些html字符串时将其发送到表单操作。
var JS_DATA = data;                             //get the js array as a variable
static List<string> data = new List<string>();  //make a new list

foreach (string str in JS_DATA)
    data.Add(String.Format("{0}", str));        //add the whole js array to the list
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head runat="server">
    <title></title>
     <script type="text/javascript">
         var array_store;
         window.onload = function () {
             array_store = document.getElementById("array_store");
             document.getElementById("array_disp").innerHTML = array_store.value;
         };
         function UpdateArray() {
             var arr;
             if (array_store.value == "") {
                 arr = new Array();
             } else {
                 arr = array_store.value.split(",");
             }
             arr.push((arr.length + 1).toString());
             array_store.value = arr.join(",");
         };
    </script>
  </head>
   <body>
    <form id="form1" runat="server">
    <span id="array_disp"></span>
    <br />
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="UpdateArray()" />
    <input type="hidden" id="array_store" name = "ArrayStore" value = '<%=this.ArrayStore %>' />
    </form>
  </body>
  </html>
   protected string ArrayStore = "";
   protected void Page_Load(object sender, EventArgs e)
   {
      this.ArrayStore = Request.Form["ArrayStore"];
   }