我有一个简单的 asp.net 网页,其中包含 2 个RadioButton
列表。提交表单时,会执行一些更复杂的代码,这需要一些时间(5-10 秒)才能执行。
我想ContentPlaceHolder
在执行该代码之前简单地更改 2 之间的可见性。切换工作,但仅在执行复杂代码之后。
结果是页面冻结并在一段时间后发生变化。
我的aspx代码:
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:PlaceHolder ID="requestpage" runat="server" Visible="true">
<p>
</p>
<h1>
Navigatie update</h1>
<p>
</p>
<div style="text-align: left; width: 300px">
<p>
Kies een site</p>
</div>
<p>
<asp:RadioButtonList ID="pubtargetid" runat="server">
</asp:RadioButtonList>
</p>
<br />
<br />
<div style="text-align: left; width: 300px">
<p>
Kies een taal</p>
</div>
<p>
<asp:RadioButtonList ID="chosenLanguage" runat="server">
</asp:RadioButtonList>
</p>
<p style="color: red">
<asp:Label ID="errorMessage" runat="server"> </asp:Label></p>
<p>
<asp:Button Text="Start update" OnClick="Submit" runat="server" />
</p>
</asp:PlaceHolder>
<asp:PlaceHolder ID="responsepage" runat="server" Visible="False">
<p>
</p>
<h1>
Navigatie update</h1>
<p>
Navigatie wordt geüpdate</p>
<p>
</asp:PlaceHolder>
我背后的代码:
using System;
using System.Web.UI.WebControls;
using System.Threading;
using Tridion.ContentManager.CommunicationManagement;
using Tridion.ContentManager;
namespace CustomPages
{
public partial class Navigation : System.Web.UI.Page
{
private Session session;
protected void Page_Load(object sender, EventArgs e)
{
session = new Session(Request.ServerVariables["LOGON_USER"]);
Response.BufferOutput = true;
Response.Flush();
if (!Page.IsPostBack)
{
var targets = session.SystemManager.GetPublicationTargets();
pubtargetid.Items.Clear();
foreach (PublicationTarget t in targets)
{
var radio = new ListItem(t.Title, t.Id);
pubtargetid.Items.Add(radio);
}
chosenLanguage.Items.Clear();
var nl = new ListItem("NL", "NL");
var fr = new ListItem("FR", "FR");
chosenLanguage.Items.Add(nl);
chosenLanguage.Items.Add(fr);
}
}
public void Submit(object sender, EventArgs e) // --> when submitting the form
{
if (pubtargetid.SelectedIndex != -1 && chosenLanguage.SelectedIndex != -1)
{
requestpage.Visible = false;
responsepage.Visible = true;
Response.Flush();
String pageId ="";
String target = pubtargetid.SelectedItem.Value;
String lang = chosenLanguage.SelectedItem.Value;
//some code//
var nav = new Automations.Navigation(session,page);
nav.CheckPage(pageId, target); // --> complex piece of code
}
else
{
errorMessage.Text = "";
if (pubtargetid.SelectedIndex == -1)
{
errorMessage.Text += "Choose a publication target. \n";
}
if (chosenLanguage.SelectedIndex == -1)
{
errorMessage.Text += "Choose a language.";
}
}
}
}
}
简而言之:我想让可见性在执行该复杂代码之前发生变化。
我尝试了不同的选择;就像试图刷新响应,但我没有成功,Response.BufferOutput = false
还有一次= true
,但仍然没有成功!
对此问题的任何帮助将不胜感激!