两个都是自己写的aspx 网站。现在我想通过a网站中的网页 提交网页中的两个textbox 值给b网站中的网页。B接受是用Request.Form 来接收的。原来a 是用http写的,可以很容易的提交出去。
现在a 要改成aspx来写,我找了半天都没有找到该如何模拟这个表单来提交。不知道是不是这个说法。这里先谢谢各位了,谢谢,谢谢,再谢谢。旁白:实在不行我只好用Response.Redirect 后面带变量的办法了那样实在太麻烦了,还要对字符串进行加密。

解决方案 »

  1.   

    http写的?   不明白.
    aspx模拟个表单很容易.有<form 和元素就行.
      

  2.   


    不行,这个接不到,除非用Response.Redirect  也就是Http里面带参数才可以的。
    我再试试看。
      

  3.   


    就是原来是用http写的,提交表单后,另外一个页面是用aspx写的,接也很容易用Request.Form 就可以把参数接到了。问题是现在吧这个http的网页改成用aspx写了。
    这下问题出现了,另外一个用Request.Form 怎么也接不到。问题是如何A aspx的页面 跳转到B aspx页面,并且B aspx页面能用Request.Form  接收到 A aspx 页面上的 两个textbox值。
      

  4.   

    你说的那个url传值吧?
    其实跨页面提交,还有个方法(dotnet 2.0以后支持)就是利用http://activer.cnblogs.com/archive/2006/03/16/351274.html
    look
      

  5.   

    lz 你到google搜索一下 .net MVC吧,上面教程挺全的
    但是我没用过
      

  6.   


    再加个<form 地址指向B.aspx,用这个form提交肯定可以.
      

  7.   

    楼主太有少了吧。http写的?http是协议,aspx是动态技术,牛头不对马嘴呀。
    我看你是用HTML写的吧,不是用http写的。aspx一样可以写html代码呀。
      

  8.   


    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">
    </script><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="formPost" action="B.aspx" method="post">
            <div>
                <input name="txtPostValue" type="text" />
                <input type="submit" />
            </div>
        </form>
        <form id="formGet" action="B.aspx">
            <div>
                <input name="txtGetValue" type="text" />
                <input type="submit" />
            </div>
        </form>
    </body>
    </html>
    <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(Request.Form["txtPostValue"]);
            Response.Write(Request.QueryString["txtGetValue"]);
        }
    </script><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>
      

  9.   

    大家说的好像都是一个办法这里先问问,我的两个页面不是在一个网站下的,这样有没有关系也就是说一个是wwww.k1/a. aspx.  另外一个是www.k2/b.aspx
    这样上面的办法还可行吗?我这就去试试看。先谢谢各位了。
      

  10.   


    试过了还是不行是不是我哪里出错了,现在写一个简单的来试试看。另外这两个页面不是在一个网站内的,估计也是一样使用吧?
    还问问一个问如何 吧字符串给简单加密了,比如用System .Text .Encoding .ASCII 把字符串变成乱码,接的时候在转回正常值
      

  11.   

    简单代码如下
    A   提交页面代码 <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Index.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server" action="http://localhost:2007/testB/Index.aspx">
        <div>
        
            <asp:TextBox ID="id" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        
        </div>
        </form>
    </body>
    </html>
    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {    }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("http://localhost:2007/testB/Index.aspx");    }
    }B 接受页面代码如下
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Index.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Form["id"] != null)
            {
                string k = Request.Form["id"].ToString();
            }
        }
    }
    就是A要怎么提交出去,B才能接到到这个Request.Form["id"]
    我语文水平不好,大家还是看代码更简单些呵呵。
      

  12.   

    1.第一个基础html知识,Request.Form 接收的是Name值,而非ID值
    2.第二个基础asp.net知识,asp.net的控件的ID和Name值是一样第,但是其在客户端表现是control.clientID而非control.ID
    3.第三个基础知识asp.net本身也是可以跨页提交滴,如果是使用自己带的跨页提交就不存在上述问题,不过asp.net自己带的跨页提交有另外的接收方式
    建议lz装一个HTTP Analyzer插件,你就可以看到具体的提交参数,呵呵,这个工具还是挺有用滴,尤其是做ajax一类隐藏提交时候,调错很方便
      

  13.   

    呵呵谢谢了,
    请问一下.net自己有哪些夸网页提交的办法(不是同一个服务器)
      

  14.   

     <form id="form1" runat="server" action="http://localhost:2007/testB/Index.aspx"> 问题出在runat="server"  你加上了它则无法实现跳转。具体自己google
      

  15.   

    用Post提交好像可以吧,曾经用过Request.Form从支付服务网站接收过返回的数据,不过asp.net要用Post提交数据,必须是2.0才行,1.1都是跳转到自身的
      

  16.   

    直接后台 Server.Transfer(url)
      

  17.   

    http://tech.ddvip.com/2008-10/122362729576393.html
      

  18.   

    http://school.cnd8.com/dot-net/jiaocheng/3396.htm
      

  19.   

    你的这个问题也许是两个网站之间传递数值的问题吧:
    方案一:生命一个[WebMethod]方法,这个方法中包含TextBox1和TextBox2的方法,然后再网站B中通过远程服务调用的方法获取这两个值,这样可以避免安全问题。
    方案二:把你要传递的制作串行化处理,然后再网站B中进行读取。
      

  20.   

    aspx 提交默认是处理是他自己,要设置他的action。