当前位置: 代码迷 >> ASP.NET >> 怎么进行post跨页提交
  详细解决方案

怎么进行post跨页提交

热度:8853   发布时间:2013-02-26 00:00:00.0
如何进行post跨页提交?
有一目标网站a.jsp接受username和password这两个post变量。

我的页面上有两个文本框:
<asp:TextBox   ID= "username "   runat= "server "   > </asp:TextBox>
<asp:TextBox   ID= "password "   runat= "server "   > </asp:TextBox>
那我想提交到a.jsp,那时不是在asp:button设PostBackUrl就可以了?

问题来了,这个aspx我是放在masterpage下的,出来的代码变成
<input   name= "ctl00$ContentPlaceHolder1$txbUserName "   type= "text "   id= "ctl00_ContentPlaceHolder1_txbUserName "/>

a.jsp现在接收到的是ctl00$ContentPlaceHolder1$username,而不是原来的username,a.jsp我没有权利去修改,该如何解决这个提交问题?

------解决方案--------------------------------------------------------
反正这个aspx不需要提交到自己的页面,那就没有必要用textbox了.用input 就可以了.
------解决方案--------------------------------------------------------
<asp:TextBox只能提交给当前页,要提交给不同的页,必须使用input中的text控件。
<form action= "a.jsp " method= "post ">
<input type= "text " id= "username ">
<input type= "password " id= "password ">
<button type= "submit " value= "提交 ">
</form>
------解决方案--------------------------------------------------------
刚刚好做了一个
function Post(str)
{

var xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP ");
var xmldoc = new ActiveXObject( "Msxml.DOMDocument ");
xmlhttp.Open( "POST ", "PostSalesReport.aspx ",false);
xmlhttp.setRequestHeader( "Content-Type ", "application/x-www-form-urlencoded ");
xmlhttp.Send(str);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
alert(xmlhttp.responseText)
}
}
if(xmlhttp.status!=200)
{
alert ( '网络故障(xmlhttp.status= '+xmlhttp.status+ '),请稍后再试! ');
return false;
}
var info = xmlhttp.responseText;
info=info.substr(0,(info.indexOf( ' <! ')));
if(info.indexOf( '成功 ')> 0)
{
window.opener=null;window.returnValue =1;window.close()
}
alert(info);
}


PostSalesReport.aspx
if(!Page.IsPostBack)
{
if(Request.Form[ "PKID "]!=null)
{
cDsc.Application=Server.UrlDecode(Request.Form[ "Application "].ToString());
cDsc.End_Customer=Server.UrlDecode(Request.Form[ "End_Customer "].ToString());
cDsc.Expect_price=Request.Form[ "Expect_price "].ToString();
cDsc.PKID=int.Parse(Request.Form[ "PKID "].ToString());
//cDsc.Potential=Server.UrlDecode(Request.Form[ "Potential "].ToString());
cDsc.PP=Server.UrlDecode(Request.Form[ "PP "].ToString());
cDsc.Projcet=Server.UrlDecode(Request.Form[ "Project "].ToString());
cDsc.Region=Server.UrlDecode(Request.Form[ "Region "].ToString());
cDsc.Sales=Server.UrlDecode(Request.Form[ "Sales "].ToString());
cDsc.Status=Server.UrlDecode(Request.Form[ "Status "].ToString());
cDsc.Type=Server.UrlDecode(Request.Form[ "Type "].ToString());
string err=Bss.Update(cDsc);
try
{
int i=int.Parse(err);
Response.Write ( "保存成功! ");
}
catch
{
Response.Write (err);
}
}
else
{
Response.Clear();
Response.End();
}
}


------解决方案--------------------------------------------------------
  相关解决方案