webform Server.Execute无法按预期工作 [英] webform Server.Execute not working as expected

查看:61
本文介绍了webform Server.Execute无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个名为default.aspx的asp webform和一个名为webform1.aspx的第二个。使用default.aspx登录后,我想从default.aspx中多次调用webform1来回传递Session变量。为了测试这个,我用我的两个表单创建了一个简单的Web应用程序,如下所示:



Server.Execute调用webform1.aspx但不显示webform1页面。它在执行后返回到server.execute语句之后的行。我需要每次调用webform1页面时显示,以便我可以接受输入。有人可以让我知道我做错了吗?



问候

Pat





default.aspx.cs

public partial class _Default:Page

{

string status =active;

protected void Page_Load(object sender,EventArgs e)

{



}



protected void Button1_Click(object sender,EventArgs e)

{

while( status ==active)

{

Server.Execute(〜/ WebForm1.aspx);

}

}



webform1.aspx.cs

公共部分类WebForm1:System.Web。 UI.Page

{

protected void Page_Load(object sender,EventArgs e)

{



}



protected void Button1_Click(object sender,EventArgs e)

{

return;

}

}

Hello,
I have an asp webform called default.aspx and a 2nd called webform1.aspx. After logging in with default.aspx I would like to call webform1 multiple times from default.aspx passing Session variables back and forth. To test this I created a simple web application with my two forms as shown below:

Server.Execute calls webform1.aspx but the webform1 page does not display. It returns to the line after the server.execute statement after executing. I need the webform1 page to display each time it is called so that I can accept inputs. Can some let me know what I am doing wrong?

regards
Pat


default.aspx.cs
public partial class _Default : Page
{
string status="active";
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
while(status == "active")
{
Server.Execute("~/WebForm1.aspx");
}
}

webform1.aspx.cs
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
return;
}
}

推荐答案

Server.Execute 调用页面代码后台线程。要基本导航到新页面,您需要使用 Server.Redirect()。这会将执行传递给下一页。然后,您需要重定向返回原始页面以创建页面循环。
Server.Execute calls the page code in a background thread. To basically navigate to a new page you will need to use Server.Redirect(). This will pass the execution to the next page. From there you will need to then Redirect back to the original page to create the page loop.


这篇关于webform Server.Execute无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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