How realizes the postback event in the cache page

G

Guest

Hi,
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


code:
<%@ 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,
b.ID.ToString()));
PlaceHolder1.Controls.Add(b);
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));

HtmlInputButton c = new HtmlInputButton();
c.ID = "mybutton2";
c.Value = "Click";
c.Attributes.Add("onclick", cs.GetPostBackEventReference(this,
c.ID.ToString()));
PlaceHolder1.Controls.Add(c);
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());
PlaceHolder1.Controls.Add(a);
}
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
{
Label1.Text = "Postback handled by " + this.ID.ToString() + ".
<br/>" +
"Postback caused by " + eventArgument.ToString() +
"."; ;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top