方法发布问题 [英] method post problem

查看:62
本文介绍了方法发布问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的default.aspx文件中,我有以下代码。

当我去浏览器时,我在两个文本框中输入值,然后我点击提交

按钮,

然而,它没有去page2.aspx。相反,它仍然在默认页面。

我认为Action将页面指向page2.aspx,没有???

< form id =" Form1"方法= QUOT;交" RUNAT = QUOT;服务器" action =" page2.aspx">

< asp:TextBox id =" TextBox1" runat =" server">< / asp:TextBox>

< asp:TextBox id =" TextBox2" runat =" server">< / asp:TextBox>

< asp:Button id =" Button1" RUNAT = QUOT;服务器" Text =" Button">< / asp:Button>

< / form>

解决方案

您好布兰妮,


"跨页回发"不是ASP.NET 1.x的一个功能,因为你只是发现了
。但它是ASP.NET 2.0中的一个功能(目前处于测试版本中),其中一个按钮可以具有PostBackUrl属性的值。您可以在ASP.NET 2.0快速入门教程中阅读有关此功能的内容。
http://beta.asp.net/QUICKSTART/aspne...s/default.aspx


目前,你必须使用Server.Transfer(URL,bool)来响应

a ButtonClick事件将你的表单转移到另一个页面; bool参数

将决定是否要保持(true)或清除(false)表单和

QueryString集合。此链接具有传输的完整语法

方法:
http://msdn.microsoft.com/library/de...nsfertopic.asp


-

HTH,

Phillip Williams
http://www.societopia.net
http://www.webswapp.com

" Britney"写道:

大家好,
在我的default.aspx文件中,我有以下代码。
当我去浏览器时,我在两个文本框中输入值,然后我点击提交
按钮,
然而,它没有去page2.aspx。相反,它仍然在默认页面。
我认为Action将页面指向page2.aspx,没有???

< form id =" Form1"方法= QUOT;交" RUNAT = QUOT;服务器" action =" page2.aspx">
< asp:TextBox id =" TextBox1" runat =" server">< / asp:TextBox>
< asp:TextBox id =" TextBox2" runat =" server">< / asp:TextBox>
< asp:Button id =" Button1" RUNAT = QUOT;服务器" Text =" Button">< / asp:Button>
< / form>



使用服务器控件,例如文本框和下面的按钮,ASP.NET

依赖于回发后的功能。如果您在html页面上查看源代码,您将会看到ACTION属性已被更改。


或者,在button_click的代码隐藏中活动你可以

server.transfer或response.redirect到另一页。


" Britney"写道:

大家好,
在我的default.aspx文件中,我有以下代码。
当我去浏览器时,我在两个文本框中输入值,然后我点击提交
按钮,
然而,它没有去page2.aspx。相反,它仍然在默认页面。
我认为Action将页面指向page2.aspx,没有???

< form id =" Form1"方法= QUOT;交" RUNAT = QUOT;服务器" action =" page2.aspx">
< asp:TextBox id =" TextBox1" runat =" server">< / asp:TextBox>
< asp:TextBox id =" TextBox2" runat =" server">< / asp:TextBox>
< asp:Button id =" Button1" RUNAT = QUOT;服务器" Text =" Button">< / asp:Button>
< / form>






我在我的代码隐藏cs文件中尝试了以下内容,但它不起作用。


我没看到它重定向到testing2.aspx ..


所以这很奇怪,任何想法?


private void Button1_Click(object sender,System.EventArgs e)


{

Server.Transfer(" testing2.aspx",true);


}


" Phillip Williams" <博士************** @ webswapp.com>在留言中写道

news:18 ********************************** @ microsof t.com ...

你好布兰妮,

跨页回发不是ASP.NET 1.x的一个功能,正如您刚刚发现的那样。但它是ASP.NET 2.0中的一项功能(目前处于测试版发布),其中按钮可以具有PostBackUrl属性的值。您可以在ASP.NET 2.0快速入门教程中了解此功能
http://beta.asp.net/QUICKSTART/aspne...s/default.aspx

目前,你将不得不使用Server.Transfer(URL,bool)作为回应
的ButtonClick事件将表单转移到另一个页面; bool
参数
将确定是否要保留(true)或清除(false)Form和
QueryString集合。此链接具有传输
方法的完整语法:
http://msdn.microsoft.com/library/de...nsfertopic.asp

- -
HTH,
Phillip Williams
http://www.societopia .net
http://www.webswapp.com

" Britney"写道:

大家好,
在我的default.aspx文件中,我有以下代码。
当我去浏览器时,我在两个文本框中输入值,然后我点击提交
按钮,
然而,它没有去page2.aspx。相反,它仍处于默认页面。
我认为Action将页面指向page2.aspx,没有???

< form id =" Form1"方法= QUOT;交" RUNAT = QUOT;服务器" action =" page2.aspx">
< asp:TextBox id =" TextBox1" runat =" server">< / asp:TextBox>
< asp:TextBox id =" TextBox2" runat =" server">< / asp:TextBox>
< asp:Button id =" Button1" runat =" server"
Text =" Button">< / asp:Button>
< / form>



Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn''t go to page2.aspx. instead, it was still in default page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</form>

解决方案

Hi Britney,

"Cross page postback" is not a feature of ASP.NET 1.x, as you just
discovered. It is however a feature in ASP.NET 2.0 (currently in beta
release) where a button can have a value for a PostBackUrl property. You can
read about this feature on the ASP.NET 2.0 Quickstart tutorials
http://beta.asp.net/QUICKSTART/aspne...s/default.aspx

Currently, you would have to use Server.Transfer(URL, bool) in response for
a ButtonClick event to transfer your form to another page; the bool parameter
would determine if want to keep (true) or clear (false) the Form and
QueryString collections. This link has the full syntax of the transfer
method:
http://msdn.microsoft.com/library/de...nsfertopic.asp

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:

Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn''t go to page2.aspx. instead, it was still in default page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</form>



With Server Controls, such as the text boxes and the button below, ASP.NET
relies on post-back capability. If you view-source on the html page you will
see that the ACTION attribute has been changed.

Alternatively, in the code-behind for the button_click event you can
server.transfer or response.redirect to the other page.

"Britney" wrote:

Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn''t go to page2.aspx. instead, it was still in default page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</form>





I tried the following in my code-behind cs file, but it doesn''t work.

I don''t see it redirect to testing2.aspx..

So this is strange, any idea?

private void Button1_Click(object sender, System.EventArgs e)

{
Server.Transfer("testing2.aspx", true);

}

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:18**********************************@microsof t.com...

Hi Britney,

"Cross page postback" is not a feature of ASP.NET 1.x, as you just
discovered. It is however a feature in ASP.NET 2.0 (currently in beta
release) where a button can have a value for a PostBackUrl property. You
can
read about this feature on the ASP.NET 2.0 Quickstart tutorials
http://beta.asp.net/QUICKSTART/aspne...s/default.aspx

Currently, you would have to use Server.Transfer(URL, bool) in response
for
a ButtonClick event to transfer your form to another page; the bool
parameter
would determine if want to keep (true) or clear (false) the Form and
QueryString collections. This link has the full syntax of the transfer
method:
http://msdn.microsoft.com/library/de...nsfertopic.asp

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:

Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn''t go to page2.aspx. instead, it was still in default
page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</form>



这篇关于方法发布问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆