By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

How realizes the postback event in the cache page

P: n/a
I use post way realization page postback this am must,How realizesunder the
post way controls postback continuously to be unable to findthe solution the
method to hope can obtain master's help in here

Cannotuse VaryByControl
<%@ OutputCache Duration="100000" VaryByParam="page;category" %>
<%= DateTime.Now.ToString() %>
<asp:Button ID="button1" runat=server Text="click"
OnClick="Button1_Click" />
<asp:Label ID="label1" runat=server></asp:Label>

protected void Button1_Click(object sender, EventArgs e)
this.label1.Text = DateTime.Now.ToString();
i have used other codes cannot realize:
protected void Page_Load(object sender, EventArgs e)
ClientScriptManager cs = Page.ClientScript;

// Create a button element with its onClick attribute defined
// to create a postback event reference to the custom label control.
HtmlInputButton b = new HtmlInputButton();
b.ID = "mybutton1";
b.Value = "Click";
b.Attributes.Add("onclick", cs.GetPostBackEventReference(this,
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));

HtmlInputButton c = new HtmlInputButton();
c.ID = "mybutton2";
c.Value = "Click";
c.Attributes.Add("onclick", cs.GetPostBackEventReference(this,
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));

// Create a link element with its href attribute defined
// to create a postback event reference to the custom label control.
HtmlAnchor a = new HtmlAnchor();
a.ID = "myanchor1";
a.InnerText = "link";
a.HRef = cs.GetPostBackClientHyperlink(this, a.ID.ToString());
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
Label1.Text = "Postback handled by " + this.ID.ToString() + ".
<br/>" +
"Postback caused by " + eventArgument.ToString() +
"."; ;

Aug 5 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.