Last post Oct 30, 2007 12:52 PM by amir36
Oct 23, 2007 03:40 PM|amir36|LINK
I have button inside an updatePanel both created dynamically with databound accordion in contentTemplate
when I call _doPostBack on that button first time works fine that is I get asynchronous postback
second time i call _doPostback I get full page postback
after that all calls work fine and give me an asynchronous postback
the calls are made on a SelectedIndex propertyChanged event
please help me know why does this happens?
thanks in advance amir
Oct 23, 2007 08:13 PM|ysw|LINK
if you disable async postbacks on ScriptManager, does everything work smoothly? I do not recommend you to disable async postbacks, but sometimes it helps to see other prolems which are not easy to see with syncpostbacks.
Oct 24, 2007 07:44 AM|amir36|LINK
When I use only sync postbacks
everything works great eccept of course that the page flashes on each postback whitch is not the behavior I want
Oct 24, 2007 09:58 AM|NNM|LINK
When you create the controls dynamically, you also need to create a postback trigger dynamically and add it to the updatepanel.
Something like this:
As LinkButton = e.Item.FindControl("sampleLink1")
Postback1.ControlID = LinkButton1.UniqueID
Oct 24, 2007 11:31 AM|amir36|LINK
I have added a dynamic trigger
but I still getting the same result
even pressing the button itself directly causes the same thing to happen (that is on second click I get a full postback)
Oct 26, 2007 03:38 PM|louisdegrazia|LINK
Is your update panel's mode conditional?
Oct 26, 2007 03:59 PM|amir36|LINK
all my updatePanels mode are conditional
I'v posted my code at another post here bearing more or less the same question?
Oct 26, 2007 05:09 PM|louisdegrazia|LINK
I see. What if you just register the control as the trigger, omitting the event?
Oct 26, 2007 05:35 PM|amir36|LINK
I'v tried that too and got the same result
now I change the code to doPostBack on the updatePanel itself and steel got the same effect.
I tried dropping from my code all the controls that were inside the updatePanel
and doPostback on the updatePabel still got me the same result.
Oct 29, 2007 04:38 AM|Jonathan Shen – MSFT|LINK
You should register the trigger after an asynchronous postback. Here is the sample.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Reflection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
//use refrection to register a asyncpost button here.
private static MethodInfo triggerInitMethod = typeof(UpdatePanelTrigger).GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Instance);
protected void Page_Load(object sender, EventArgs e)
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = this.Button1.UniqueID;
trigger.EventName = "Click";
<head id="Head1" runat="server">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
I hope this help.
Oct 29, 2007 08:04 AM|amir36|LINK
I loked at source view in browser and see that the arrays of updatePanels and Buttons were not registered
with the new controls ClientID and were still the with the old ones
even though the line
var bt = $get(Buttons[parseInt(sender.get_ClientState())]);
bt was not null (bt.id was the old clientID) but probably "doPostback('bt.id'','')"
cause it did a postback as if I wrote doPostback('', '')
sorry for my complicated explanation
hope you will understand what I have described
and thanks again for your your answers
Oct 30, 2007 02:30 AM|Jonathan Shen – MSFT|LINK
I have tested my sample code once more and it works pretty well. So would you please wholly copy it to your project and have a test.
Oct 30, 2007 06:54 AM|amir36|LINK
Your code is written in Page_Load for a static updatePanel
but my problem is that my updatePanels are created dynamically inside a datbound accordion control contentTemplate
I have used your code in the above event handler but still it didnt behave properly on doPostBack
I still think that it somthing to do with the registration of the client script somthing got lost there
take another look at the code I posted in
http://forums.asp.net/p/1171622/1962373.aspx#1962373 and see my problem
I thank you for your time
Oct 30, 2007 07:24 AM|Jonathan Shen – MSFT|LINK
Ok , please do me a favor. Would you please post the repro and reduce all the unnecessary part so that I can wholly copy your code and reproduce your issue. Thanks.
Oct 30, 2007 12:52 PM|amir36|LINK
Here is all my code
you'll noticed when you run it on the second click on one of headers of the accordion
there is a full page postback
I have found a way around it with an intial postback on pageLoad
(uncomment the if statement in accordion1_preRender and youll see how I wants it to work. but thats not good enough for I dont know why it happen in the first place)