62,047
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
this.bt.Click += new EventHandler(PanelUpdate); //添加事件委托
}
void PanelUpdate(object sender, EventArgs e)
{
this.UpdatePanel1.Update();
}
protected void bt_Click(object sender, EventArgs e) //Button点击事件
{
...... ///一些代码
}
public partial class Header : System.Web.UI.UserControl
{
public event Action<string> CodeSession_Changed;
protected void search_Click(object sender, EventArgs e)
{
if (!this.TextBox1.Text.Equals(""))
{
if (this.CodeSession_Changed != null)
this.CodeSession_Changed(this.TextBox1.Text);
}
}
}
public partial class Header : System.Web.UI.UserControl
{
public event Action CodeSession_Changed;
protected void search_Click(object sender, EventArgs e)
{
if (!this.TextBox1.Text.Equals(""))
{
if (this.CodeSession_Changed != null)
this.CodeSession_Changed();
}
}
public string Text
{
get
{
EnsureChildControls();
return this.TextBox1.Text;
}
}
}
public partial class content : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
RefreshLiteral(null);
}
public void RefreshLiteral(string str)
{
if (str == null)
this.Literal1.Text = "Session 为空";
else
this.Literal1.Text = str;
}
}
public partial class Header : System.Web.UI.UserControl
{
public event Action CodeSession_Changed;
protected void search_Click(object sender, EventArgs e)
{
if (!this.TextBox1.Text.Equals(""))
{
Session["code"] = this.TextBox1.Text;
if (this.CodeSession_Changed != null)
this.CodeSession_Changed();
}
}
}
这样当你修改了Session集合中的数据之后,就可以通知其它程序继续处理。public partial class content : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
RefreshLiteral();
}
public void RefreshLiteral()
{
if (Session["code"] == null)
this.Literal1.Text = "Session 为空";
else
this.Literal1.Text = Session["code"].ToString();
}
}
<uc1:Header ID="Header1" runat="server" OnCodeSession_Changed="session_changed" />
protected void session_changed()
{
content1.RefreshLiteral();
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="bt" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Literal ID="Literal1"runat="server" Text="<%$Resources:SharedResources, SiteTitle%>" />
</ContentTemplate>
</asp:UpdatePanel>