如何触发用户控件更新
问题描述:
有没有简单的方法来从另一个用户控件更新用户控件?如何触发用户控件更新
我有一个输入框和一个提交按钮。用户输入代码,命中并根据代码将积分应用于其他用户控制。点数将应用于数据库中的分数,但不显示在页面显示中,直到我刷新。有没有简单的方法来更新提交控件?谢谢。
----------背后提交按钮--------------
protected void btn_Add_Coupon_Click(object sender, EventArgs e)
{
try
{
SqlDataSourceTEST.DataSourceMode = SqlDataSourceMode.DataReader;
IDataReader Reader = (IDataReader)SqlDataSourceTEST.Select(DataSourceSelectArguments.Empty);
if (Reader.Read())
{
int iPoints = 0;
iPoints = (int)Reader["Points"];
if (iPoints > 0)
{
Profile.TimesVisited = Profile.TimesVisited + iPoints;
lblcoup.Text = iPoints.ToString() + " have been added to your score!";
}
else
{
lblcoup.Text = "Coupon Code Not Valid";
}
}
Reader.Close();
Reader.Dispose();
}
catch (Exception ex)
{
}
}
答
看看这篇文章代码:http://www.dotnetcurry.com/ShowArticle.aspx?ID=155&AspxAutoDetectCookieSupport=1
它解释了如何访问另一个用户控件。
希望这会有所帮助。