Showing posts with label postback. Show all posts
Showing posts with label postback. Show all posts

Wednesday, March 28, 2012

dynamic html production to call ajax post via javascript

I am maintaining a page that creates html (not server controls) elements dynamically and when one changes I need to call the ajax postback. Is that possible? The page that is created can't know ahead of time that it will need to post through ajax....

So long as you add a client-side Event handler to your html control when you create it, yes, you can wire it up to make asynchronous requests:http://www.mikesdotnetting.com/Article.aspx?ArticleID=40. Note, the methodology outlined in the article doesn't make an ASP.NET Ajax request or postback. It differs in that it only makes a call to the server-side method you want to invoke. This can be better than using ASP.NET Ajax, in that you aren't recreating all the controls on the page.

Dynamic create UpdatePanel during postback

Hi,

I want to add a UpdatePanel into page dynamically during postback, see bellow code for detail. The problem is although UpdatePanel control was successful created, I cannot get its reference in later postback times.

// dummy template
publicclassMyTemplate :ITemplate
{
publicvoid InstantiateIn(Control container)

{

}

}

// create UpdatePanel during postback
protectedvoid Button5_Click(object sender,EventArgs e)
{

Microsoft.Web.UI.UpdatePanel u =new Microsoft.Web.UI.UpdatePanel();

u.ID ="udpDynamic";

u.ContentTemplate =newMyTemplate();

u.Mode = Microsoft.Web.UI.UpdatePanelMode.Conditional;

Microsoft.Web.UI.ControlEventTrigger trigger =new Microsoft.Web.UI.ControlEventTrigger();

trigger.ControlID ="Button6";// this button is created in design time

trigger.EventName =

"Click";

u.Triggers.Add(trigger);

this.Form.Controls.Add(u);

}

// other postback event
protectedvoid Button6_Click(object sender,EventArgs e)
{

Label test =newLabel();

test.Text ="I'm new portlet " +DateTime.Now.ToLongTimeString();

Microsoft.Web.UI.UpdatePanel u = (Microsoft.Web.UI.UpdatePanel)this.Form.FindControl("udpDynamic");

u.Controls.Add(test);// error! u is null

}

// here is HTML code generated, as I can see the UpdatePanel control was created successfully
<div id="udpDynamic"></div>

<components>
<pageRequestManager id="_PageRequestManager" updatePanelIDs="UpdatePanel1,UpdatePanel2,UpdatePanel3,udpDynamic" asyncPostbackControlIDs="Button4,Button6" scriptManagerID="ScriptManager1" form="form1" />
</components>

Well, I can't solve your problem, but I can tell you one thing that is wrong with your code:

When adding a control to an UpdatePanel, you need to use the ContentTemplateContainer.Controls.Add(...) property of the UpdatePanel, otherwise you will not see the control (in a book I read, it will actually throw an error, but I guess it isn't for you).

I work in VB.NET, although I can usually understand C#, but when I try to convert from System.Web.UI.Control (which is what FindControl returns) to System.Web.UI.UpdatePanel, I receive the following error message:

Unable to cast object of type 'System.Web.UI.Control' to type 'System.Web.UI.UpdatePanel'.

I am surprised that you are not receiving this error as well, if you take a look at my posting athttp://forums.asp.net/t/1154222.aspx you can see more details about this problem I am having. Good Luck!

Dynamic Control creation not persisting through PostBack

Hey guys,

I've done some searching on dynamic control creation in the forums, but none of them take me to an Atlas page. I'm trying to build a HR Notification form with some simple Atlas UpdatePanels. Basically, I want to dynamically add Labels and TextBoxes to this form. For instance, if you select 3 from the Number of Children DDL, I want 3 child forms to be created under it. I've been able to create the forms (at least theoretically, I just create "test" Labels right now). The problem I'm running into is being able to read from these dynamically created Controls.

When I submit the form as a regular PostBack, all of my created labels seem to be lost. I get null exceptions when I try to use FindControl. Here are some code snippets:

protected void ddlNumChildren_SelectedIndexChanged(object sender, EventArgs e) {int runNum = Convert.ToInt32(ddlNumChildren.SelectedValue.ToString());int count = 0;while (count < runNum) { Label text=new Label(); text.ID ="testLabel" + count; text.Text ="test"; phNumChildren.Controls.Add(text); count++; } }protected void btnSubmit_Click(object sender, EventArgs e) {int runNum = Convert.ToInt32(ddlNumChildren.SelectedValue.ToString());int count = 0;while (count < runNum) { Label lbltest = phNumChildren.FindControl("testLabel" + count)as Label; Response.Write(lbltest.Text); } }

I'm assuming I have to save this data before the postback, but I need a little help in how I can do this. Thanks for your time and any help you can provide.

The problem is that the controls do not exist when the page is recreated during postback. You have two options :
1) Recreate the page during the Init() event if you have atlas UpdatePanels or Page_Load() if not
2) try http://www.denisbauer.com/ASPNETControls.aspx
3) Write your own code to save all controls in ViewState and reload them during the Init() event

Saturday, March 24, 2012

Dropdowns inside updatepanel flash on postback.

I have 2 dropdown controls inside an updatepanel. One is disabled or enabled dependent on the selection of the other dropdown. The disabled one has its autopostback property set to false. The other one has autopostback=true. When I make selection in dropdown 1, both dropdowns flash. Is there a way to prevent the redrawing of the controls and just have the data in them update?

Thanks,

John

Put the both the DropDownlist control in to its own UpdatePanel.And make the second updatepanel Updatemode ="Conditional" and when you want to second DDL to be enable do it in the code and call the update() method in the UpdatePanel two ..

refer the following link for more information

http://asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx

Dropdownlist is flickering During Asynchronous Postback

I have placed dropdownlist along with some other controls in an Update panel.During Async Postback, the dropdownlist is flickering. Can any one help me to avoid the flickering of Dropdownlist

Anything in the update panel may flicker. If you don't want something to, you may want to take it out of the update panel. You can use it as a trigger if you are changing something based of the selected index when it changes.

I have noticed this as well. I tried to figure it out for a day or so and I'm taking a break from it. Hopefully someone will answer.

I don't see this behaviour with text boxes though...


It could also be more noticeable if you have a large number of items in the dropdown and more noticeable if they are bound to it. As I said in my previous reply, you can remove it from the update panel if you do not need to change the dropdown's contents by placing it outside the update panel.

Wednesday, March 21, 2012

DropDownList flicker problem

Environment: VS 2005 with Atlas

Problem: I have some textboxes and dropdownlists on a page. When I click on any link to do a postback; all the dropdownlists disappear for few milliseconds and then reappear.

Note: I am not populating the dropdownlist again.

I want to avoid this flicker of dropdownlists.

If anyone has some across suck an issue, please help.

-Jagdish Yadav

Hi there,

Just wonder if you have a code snippet showing this problem.

Regards


Hi,

This is not related to any code. It happens on anyone's page.

If you have a dropdownlist on a page. And to avoid flicker of the page during postback you have applied atlas solution. Then if you do a postback, all the controls on the page remain as they are. But the dropdownlist will flicker (i.e.: it will disappear for a second and come back again). Even though we are not repopulating the dropdownlist on postback.

Please help...


Hi,

does it happen on any browsers?

Hi!

I have just tried this and it flickers in internet explorer but not in mozilla.
Can anybody tell me why this is′nt working?


I am experiencing the same problem. My scenario uses a drop down list in a usercontrol, which is in an update panel.

Anotherthread with the same issuehas not been resolved, however the individual noticed that using Internet Explorer 7 Beta 2 eliminates the problem. Of course this doesn't help those who would like to fix this problem for IE 6.

Has anyone found a fix yet?

Billy


Hi there,

I can confirm the issue even with the June CTP. The flicker happens for dropdownlists in IE6, not in IE7 Beta nor FireFox.

BTW: FireFox is in almost all cases more "ATLAS" aware and enabled, as the IE is... Very strange.

Regards


Hi,

this is not an issue of the Atlas framework. It is an issue in the way IE6 renders this type of boxed list.

dropdownlist disappear with ModalPopupExtender

My dropdownlist disappear if I useModalPopupExtender. It doesn't appear until there is any postback on the page.

Any solution?

Thanks,

Rahul Jain

Could you please provide more details on how your page is setup? Where is the dropdown list? A small self-sufficient repro would help. Thanks.

DropDownList controls doesnt show the data after postback.

I am using a FormView and ajaxToolkit:CollapsiblePanelExtender. My DropDownLists show the data the first time, but after I press a button and it does a post back, the DropDownLists does not show the data even though I can debug and see that I am adding the items in the code-behind. Please help.

<asp:FormViewID="FormView1"runat="server"DataKeyNames="ID"DataSourceID="CslaDataSource1"DefaultMode="Insert"Width="95%">

<InsertItemTemplate>

<tableborder="0"width="100%">

<tr>

<tdalign="left">

<asp:PanelID="description_HeaderPanel"runat="server"style="cursor: pointer;">

<div>

<asp:ImageButtonID="Description_ToggleImage"runat="server"ImageUrl="~/Image/plus.gif"AlternateText="collapse"/> Search

</div>

</asp:Panel>

<asp:Panelid="description_ContentPanel"runat="server"style="overflow:hidden;">

<tableborder="0">

<tr>

<tdcolspan="6"> </td>

</tr>

<tr>

<tdalign="right">Alert ID:</td>

<td><asp:TextBoxID="txtID"runat="server"Text='<%# Bind("ID") %>'/></td>

<td> </td>

<td> </td>

<td> </td>

<td> </td>

</tr>

<tr>

<tdalign="right"style="width:16.5%">Server:</td>

<tdstyle="width:16.5%"><asp:TextBoxID="txtServer"runat="server"Text='<%# Bind("Server") %>'/></td>

<tdalign="right"style="width:16.5%">Source:</td>

<tdstyle="width:16.5%">

<asp:DropDownListID="ddlSource"runat="server"SelectedValue='<%# Bind("Source") %>'>

<asp:ListItemValue="0"Text=""/>

</asp:DropDownList>

</td>

<tdalign="right"style="width:16.5%">Manager:</td>

<td>

<asp:DropDownListID="ddlManager"runat="server"SelectedValue='<%# Bind("Manager") %>'>

<asp:ListItemValue="0"Text=""/>

</asp:DropDownList>

</td>

</tr>

<tr>

<tdalign="right">Type:</td>

<td>

<asp:DropDownListID="ddlType"runat="server"SelectedValue='<%# Bind("Type") %>'>

<asp:ListItemValue="0"Text=""/>

</asp:DropDownList>

</td>

<tdalign="right">Severity:</td>

<td>

<asp:DropDownListID="ddlSeverity"runat="server"SelectedValue='<%# Bind("Severity") %>'>

<asp:ListItemValue="0"Text=""/>

</asp:DropDownList>

</td>

<tdalign="right">Detail:</td>

<td><asp:TextBoxID="txtDetail"runat="server"Text='<%# Bind("Detail") %>'/></td>

</tr>

<tr>

<tdalign="right">From:</td>

<td>

<asp:TextBoxID="txtFrom"runat="server"/> <asp:ImageButtonrunat="Server"ID="Image1"ImageUrl="~\Image\Calendar.png"AlternateText="Click to show calendar"/>

<ajaxToolkit:CalendarExtenderID="ajaxCalendar1"runat="server"TargetControlID="txtFrom"PopupButtonID="Image1"/>

</td>

<tdalign="right">To:</td>

<td>

<asp:TextBoxID="txtTo"runat="server"/> <asp:ImageButtonrunat="Server"ID="Image2"ImageUrl="~\Image\Calendar.png"AlternateText="Click to show calendar"/>

<ajaxToolkit:CalendarExtenderID="ajaxCalendar2"runat="server"TargetControlID="txtTo"PopupButtonID="Image2"/>

</td>

<td> </td>

<td> </td>

</tr>

<tr>

<tdalign="right">Status:</td>

<td>

<asp:DropDownListID="ddlStatus"runat="server"SelectedValue='<%# Bind("Status") %>'>

<asp:ListItemValue="0"Text=""/>

</asp:DropDownList>

</td>

<tdalign="right">Ticket ID:</td>

<td><asp:TextBoxID="txtTicketID"runat="server"Text='<%# Bind("Ticket") %>'/></td>

<td> </td>

<td> </td>

</tr>

<tr>

<tdcolspan="6"> </td>

</tr>

<tr>

<tdalign="center"colspan="6"><asp:ButtonID="btnSubmit"runat="server"Text="Submit"CausesValidation="false"CommandName="Insert"/></td>

</tr>

<tr>

<tdcolspan="6"> </td>

</tr>

</table>

</asp:Panel>

</td>

</tr>

</table>

<ajaxToolkit:CollapsiblePanelExtenderID="cpeSearch"runat="Server"TargetControlID="description_ContentPanel"ExpandControlID="description_HeaderPanel"CollapseControlID="description_HeaderPanel"Collapsed="true"ImageControlID="description_ToggleImage"ExpandedText="(Hide Details...)"CollapsedText="(Show Details...)"ExpandedImage="~/Image/minus.gif"CollapsedImage="~/Image/plus.gif"/>

</InsertItemTemplate>

</asp:FormView>

Hi, ensure your dropdownlistbox are only loaded on page load - try something like this:

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not IsPostBackThen'Load the DropdownListbox with number 1 to 10Dim aAs Int16For a = 1To 10 DrpLstTest.Items.Add(a)Next aEnd If End Sub

Thanks.

That was the first thing I tried. It didn't solve the problem.

I think the problem has to do with FormView, AJAX's CollapsiblePanelExtender, and ASP.NET.

Please help!

DropDownList causes a full page postback instead of only updating the UpdatePanel

I have a code for updating a DropDownList with items whenever another DropDownList triggers a SelectedIndexChanged event.

When I select an item in the DDLSelect dropdown, it causes a full page postback instead of just updating the UpdatePanel. This problem only occurs when I try to implement it in an existing project, and it works fine when if I try it in a new project.

I've updated my Web.config file to make my project compatible with AJAX, so I don't believe that's the problem.

I should add that I'm trying to use this inside an ascx UserControl file, so maybe there are known issues there.

Thanks in advance.

Please post the usercontrol code

OK, problem solved!

It was the Web.config after all. I had this line which caused the problem:

<

xhtmlConformancemode="Legacy"/>

I removed it and everything is fine.

Cheers.

DropDownList becomes disabled during asynch postback

The basic issue I find on my asynch postback is that two of myDropDownList controls becomes disabled during asynch postback. Once thepostback has completed I get access again to the DropDownList.

Nowmy two DropDown are in fact located within the UpdatePanel control, sonaturally it has something to do with that. Maybe its theautopostbacl=true property ?

Here are some details of my aspx Master page :

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1"runat="server"></asp:ScriptManager> <!-- note:ScriptMngr/Timer must be within form tag -->

<asp:Timer ID="TimerOrders" runat="server" Interval="5000" />
<div >
<asp:UpdatePanel ID="UpdateTally" runat="server" >
<ContentTemplate>


<asp:DropDownList ID="drpFilterList"DataSourceID="ObjectDataSourceFilterList" DataValueField="filter_id"DataTextField="f_name" AppendDataBoundItems="true" runat="server"Width="81px" AutoPostBack="True"OnSelectedIndexChanged="drpFilterList_SelectedIndexChanged"EnableViewState="true" >
<asp:ListItem Selected="True" Text="Default" Value="0" />
</asp:DropDownList>

<asp:DropDownList ID="DrpStatusList"DataSourceID="ObjectDataSourceStatusList" MaxLength="30" Width="110px"AutoPostBack="True" DataTextField="status" DataValueField="status"AppendDataBoundItems="true" runat="server"OnSelectedIndexChanged="DrpStatusList_SelectedIndexChanged" >
<asp:ListItem Value="0" Selected="true">All</asp:ListItem>
<asp:ListItem Value="LiveOrders"Selected="False">LiveOrders</asp:ListItem>
</asp:DropDownList>

</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerOrders"EventName=""/>
</Triggers>

</asp:UpdatePanel

I am facing a similar issue. Please do let me know if you find a solution!!!


Hi,robertmazzo

I test it with this demo,It works,I don't have your problem:

<%@. Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void drpFilterList_SelectedIndexChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label1.Text = ((DropDownList)sender).SelectedItem.Value + "--" + DateTime.Now.ToString();
}

protected void DrpStatusList_SelectedIndexChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label1.Text = ((DropDownList)sender).SelectedItem.Value + "--" + DateTime.Now.ToString();
}

protected void TimerOrders_Tick(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label1.Text = DateTime.Now.ToString();
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="TimerOrders" runat="server" Interval="5000" OnTick="TimerOrders_Tick" />
<div>
<asp:UpdatePanel ID="UpdateTally" runat="server">
<ContentTemplate>
<asp:DropDownList ID="drpFilterList" runat="server" Width="81px" AutoPostBack="True" OnSelectedIndexChanged="drpFilterList_SelectedIndexChanged" EnableViewState="true">
<asp:ListItem Selected="True" Text="Default" Value="0" />
<asp:ListItem Value="test" Selected="False">test</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:DropDownList ID="DrpStatusList" Width="110px" AutoPostBack="True" runat="server" OnSelectedIndexChanged="DrpStatusList_SelectedIndexChanged" EnableViewState="true">
<asp:ListItem Value="0" Selected="true">All</asp:ListItem>
<asp:ListItem Value="LiveOrders" Selected="False">LiveOrders</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerOrders" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Let me know if you need more info.

If this help you,don't forget mark it as a answer.Thanks!


Thanks for testing. I actually copied your page into a brand new page in my project and I face a similiar issue.

Ifyou select one of the DropDowns to display the list and keep your mousein place without clicking, then you should see the DropDown reset. Atthat point you need to reselect the DropDown with the mouse in order tosee the list again.

Inmy specific case (perhaps it has to dowith my master page) , the dropdown list sometimes remains displayedwhen I clickbut I cannot actually select a value for a couple of seconds. At timesI also notice that the DropDown values are cleared and I have toreselect the list (as previously mentioned).

I know users are going to complain about this because my inhouse QA tester is already noticing it.

Thank you again,

Bob


If you select one of the DropDowns to display the list and keep your mouse in place without clicking, then you should see the DropDown reset. At that point you need to reselect the DropDown with the mouse in order to see the list again. ?????

I do it just now! Haven't your problem!

You may update your IE to 7.0?


ThanksJin-Yu Yin - MSFT , your code working perfectly..

I also have IE 7


Is this is a known issue in IE6??


Okay, all you need to really do is suggest that I check myversion of IE. All the extra "?" and "!" characters are really notnecessary.

I actually have IE 7.0 on my machine. I'll test it somewhere else.

thank you for helping.

Bob


If you have time please copy this code onto your machine.

<>Here's my aspx code for Default2.aspx :

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>THIS IS ONLY A DROPDOWNLIST TEST PAGE !!!</title>
</head>
<body>
<form id="form1" runat="server">

<asp:ScriptManagerID="ScriptManager1" runat="server"/>
<asp:TimerID="TimerOrders" runat="server" Interval="4000"OnTick="TimerOrders_Tick" />

<div
<asp:UpdatePanel ID="UpdateTally" runat="server">
<ContentTemplate>
<asp:DropDownList ID="drpFilterList" runat="server" Width="81px"AutoPostBack="True"OnSelectedIndexChanged="drpFilterList_SelectedIndexChanged"EnableViewState="true">
<asp:ListItem Selected="True" Text="Default" Value="0" />
<asp:ListItem Value="test"Selected="False">test</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server"Text="Label"></asp:Label>
<asp:DropDownList ID="DrpStatusList" Width="110px"AutoPostBack="True" runat="server"OnSelectedIndexChanged="DrpStatusList_SelectedIndexChanged"EnableViewState="true">
<asp:ListItem Value="0" Selected="true">All</asp:ListItem>
<asp:ListItem Value="LiveOrders"Selected="False">LiveOrders</asp:ListItem>
<asp:ListItem Value="New Order" >New Order</asp:ListItem>
<asp:ListItem Value="Cancelled">Cancelled</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerOrders" />
</Triggers>
</asp:UpdatePanel>

</div>
</form>
</body>
</html>

Here's the .aspx.cs code :

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void drpFilterList_SelectedIndexChanged(object sender, EventArgs e)
{
//System.Threading.Thread.Sleep(3000);
Label1.Text =((DropDownList)sender).SelectedItem.Value + "--" +DateTime.Now.ToString();
}

protected void DrpStatusList_SelectedIndexChanged(object sender, EventArgs e)
{
//System.Threading.Thread.Sleep(3000);
Label1.Text =((DropDownList)sender).SelectedItem.Value + "--" +DateTime.Now.ToString();
}

protected void TimerOrders_Tick(object sender, EventArgs e)
{
//System.Threading.Thread.Sleep(3000);
Label1.Text = DateTime.Now.ToString();
}
}

--------------------------

DropDownExtender causes double postback

Hi,

Is it a known issue that the DropDownExtender causes a double postback? When this control is removed the problem doesn't happen. Worse still it gets into if(isPostBack)... Is there a work around for this?

Best regards,

Sean

Try set autopostback = false on the DropDown control.


The DropDownExtender does not have an autopostback field. I am talking about the DropDownExtender that comes with the Atlas toolkit. Also, I forgot to mention that this problem only happens in FireFox. The double postback does not happen in IE.


Hi Seeeaan,

DropDownExtender itself won't cause any postbacks. Just like the ModalPopupExtender, when drop the the element which is associated with DropDownExtender will show a panel. When click on the control inside the panel, it may cause a postback. But all this based on the clicked control instead of DropDownExtender. So would you please have a check on the controls inside the Panel. Here is a sample.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void OnSelect(object sender, EventArgs e) { lblSelection.Text = "You selected <b>" + ((LinkButton)sender).Text + "</b>."; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Label ID="TextLabel" runat="server" Text="Select your favorite exotic ice-cream flavor" Style="display: block; width: 300px; padding:2px; padding-right: 50px; font-family: Tahoma; font-size: 11px;" /> <asp:Panel ID="DropPanel" runat="server" CssClass="ContextMenuPanel" Style="display :none; visibility: hidden;"> <asp:LinkButton runat="server" ID="Option1" Text="Mocha Blast" CssClass="ContextMenuItem" OnClick="OnSelect" /> <asp:LinkButton runat="server" ID="Option2" Text="Java Cyclone" CssClass="ContextMenuItem" OnClick="OnSelect" /> <asp:LinkButton runat="server" ID="Option3" Text="Dry Fruit" CssClass="ContextMenuItem" OnClick="OnSelect" /> </asp:Panel> <ajaxToolkit:DropDownExtender runat="server" ID="DDE" TargetControlID="TextLabel" DropDownControlID="DropPanel" /> <asp:UpdatePanel id="Update" runat="server"> <ContentTemplate> <asp:Label id="lblSelection" runat="server" Style="padding: 5px;" /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Option1" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="Option2" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="Option3" EventName="Click" /> </Triggers> </asp:UpdatePanel> </form></body></html>

To find out whether a double postback occurred, we suggest that you should use a debugging tool such as Web Developer Helper, Fiddler etc.

I hope this help.

Best regards,

Jonathan


Hi Jonathan,

Ok, I shouldn't be calling it a postback. As I mentioned this problems seems to occur on Firefox but not in IE. What I meant to say is that Page_Load is triggered twice. I've set a breakpoint at if(!ispostback) when the page first loads and the breakpoint is triggered twice.

If you try this using the DropDdownExtender sample that comes with the toolkit, you will see what I mean. Again, this problem occurs with Firefox only.

Best regards,

Sean


Hi Seeeaan,

1protected int i = 0;2protected void OnSelect(object sender, EventArgs e)3 {4 lblSelection.Text ="You selected <b>" + ((LinkButton) sender).Text +"</b>.";5 }6protected void Page_Load(object sender, EventArgs e)7 {8 i++;9if (!IsPostBack) {10 i++;11 }12 }

I have added breakpoints at line 8 and 9 and then had a test(The test sample is the sample contains inside Ajax Control Toolkit). My test shows Page_Load only was fired one time but not twice.

My system environments: Windows 2003 + Visual Studio 2005 + Asp.NET 2.0 Ajax Extensions V1.0 + Ajax Control Toolkit V10618.

Test browsers: IE7 + Firefox2.0.

In your situation, If there is an asynchronous postback (some Ajax Controls,for example: AutoComplete), it will cause Page_Load is called twice.

So in brief, my suggestion is check your system environments and your code.

I hope this help.

Best regards,

Jonathan


Hmm... could be something different with my system environment. However, this problem has disappeared in the latest Control Toolkit released a few days ago.

Thanks for spending the time to have a look at this problem.

Cheers,

Sean