【发布时间】:2014-07-23 21:55:26
【问题描述】:
大家好,所以我有一点问题,知道这里有人可以帮助我,因为我无法弄清楚。
我有一个母版页,其中包含一个 div,其中包含 $ 文本框和客户在内容页面中选择服务时的总时间。
The problem I am having is that when a service is selected, the first postback does not display the updated totals on the div in master page.在第二次回发时,会显示第一次选择的结果。
我知道这是因为回发直到页面加载后才被处理。但我不知道如何解决这个问题。我尝试从内容页面的 init 方法调用处理总计更新的母版页方法,但是当我这样做时,母版页的文本框为空。
这是我的母版页代码:
namespace Teres.App
{
public partial class App : System.Web.UI.MasterPage
{
Teres.Controllers.Math M;
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "customized for: " + HttpContext.Current.Session["UserName"].ToString();
TextBox2.Text = "member: " + HttpContext.Current.Session["IsMember"].ToString();
TextBox3.Text = "membership info: " + HttpContext.Current.Session["MoreInfo"].ToString();
//need to create dynamic textboxes for service events
//will call method from Tab class
if (IsPostBack)
{
TabMath();
}
}
public void UpdateBar (string service)
{
//TextBox TextBox = new TextBox();
}
public void TabMath ()
{
M = new Teres.Controllers.Math();
string dollarTotal = Convert.ToString(M.GetDollarTotal());
TextBox29.Text = "total: $" + dollarTotal;
string minuteTotal = Convert.ToString(M.GetMinuteTotal());
TextBox30.Text = "time: " + minuteTotal + " minutes";
}
}
}
这是我的内容页面代码隐藏
namespace Teres.App
{
public partial class Services : System.Web.UI.Page
{
Teres.Controllers.Services S;
Teres.Controllers.Math M;
protected void Page_PreInit(object sender, EventArgs e)
{
}
protected void Page_Init(object sender, EventArgs e)
{
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
S = new Teres.Controllers.Services();
M = new Teres.Controllers.Math();
if(CheckBox1.Checked)
{
TextBox1.Text = S.GetHandDescription("manicure");
TextBox2.Text = Convert.ToString(S.GetHandTimes("manicure"));
TextBox3.Text = Convert.ToString(S.GetHandPrices("manicure"));
M.UpdateMinuteTotal(S.GetHandTimes("manicure"));
M.UpdateDollarTotal(S.GetHandPrices("manicure"));
//Teres.App.App.UpdateBar("manicure");
}
else
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
M.SubtractMinuteTotal(S.GetHandTimes("manicure"));
M.SubtractDollarTotal(S.GetHandPrices("manicure"));
//Teres.App.App.UpdateBar("manicure");
}
}
如何在选择后立即更新 textbox29 和 textbox30 以便回发立即显示在母版页上?
谢谢!
【问题讨论】:
标签: asp.net master-pages postback pageload