Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Wednesday, March 28, 2012

Multiple PopupControlExtender - HOW?

Hi!

For example I have 10 textbox on my page. I created a panel with a calendar inside. I use 10 PopupControlExtender to bound the same panel to every textbox. (i dont want to create 10 diffrent Panels!)

And now i have a problem: How can i found out which PopupcontrolExtener and/or Textbox opend the calendar? I need this to set the value.

Any idea?

Thank you and sorry for bad english ;-)

Make it a user control. I've already done this and other than the issues that I've noted in some other posts about the popup behavior no longer working after postback, it works just fine. Below is the code I use to create the UserControl.

<%@. Control Language="C#" AutoEventWireup="true" CodeFile="DatePicker.ascx.cs" Inherits="User_Controls_DatePicker" %>
<asp:TextBox ID="tbDateSelected" runat="server" SkinID="DateTextBox"></asp:TextBox>
<asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
<aspAjax:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<center>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999"
CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="Black" Width="160px" OnSelectionChanged="Calendar1_SelectionChanged">
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="#808080" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
</asp:Calendar>
<asp:ImageButton ID="imgCancel" runat="server" ImageUrl="../images/close.gif" OnClick="imgCancel_Click" />
</center>
</ContentTemplate>
</aspAjax:UpdatePanel>
</asp:Panel>
<ajaxToolkit:PopupControlExtender ID="pceDate" runat="server" PopupControlID="Panel1" TargetControlID="tbDateSelected" Position="Bottom" ></ajaxToolkit:PopupControlExtender>
<ajaxToolkit:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="Panel1" Radius="6" Opacity="1" TrackPosition="true" Width="5">
</ajaxToolkit:DropShadowExtender
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;
using AjaxControlToolkit;

public partial class User_Controls_DatePicker : System.Web.UI.UserControl
{
private string _selectedDate;

public string SelectedDate
{
get { return tbDateSelected.Text; }
set { tbDateSelected.Text = value; }
}

public string Position
{
set { pceDate.Position = ( PopupControlPopupPosition ) Enum.Parse( typeof( PopupControlPopupPosition ), value ); }
}

protected void Page_Load( object sender, EventArgs e )
{
}

protected void Calendar1_SelectionChanged( object sender, EventArgs e )
{
pceDate.Commit( Calendar1.SelectedDate.ToShortDateString( ) );
}
protected void imgCancel_Click( object sender, ImageClickEventArgs e )
{
pceDate.Cancel( );
}
}

Hope this helps.

Nick


You can find out which PopupControlExtender called the calendar with the info accessible by calling this following function, in the event handler for the control you popped up:

 
AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page)
You can use that in, say, your calendar's OnSelectedDateChanged event handler to see where it needs to go.

You can use the .Commit() function to submit the information from the calendar to the correct control. Once again, this would go in the event handler for your calendar's OnSelectedDateChanged event handler.

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).Commit(Calendar1.SelectedDate.toString())
 
Thanks toTed Glaza for the assist. 

Hello!

Thanks for your reply!

@.ncipollina
Thats not the right solution. I dont want to deliver 10 rendered controls (With the same content!) to the client. Thats to much overhead!

@.Matt M
Hi! That sounds interessting. But I dont get the point.

Protected Sub Calender_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim currentPopupControlExtender as AjaxControlToolkit.PopupControlExtender = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page)
currentPopupControlExtender.Commit(DirectCast(sender, Calendar).SelectedDate)
End Sub

Is this what you mean? I will try it tomorrow!


Undying:

Hello!

Thanks for your reply!

@.ncipollina
Thats not the right solution. I dont want to deliver 10 rendered controls (With the same content!) to the client. Thats to much overhead!

@.Matt M
Hi! That sounds interessting. But I dont get the point.

Protected Sub Calender_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim currentPopupControlExtender as AjaxControlToolkit.PopupControlExtender = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page)
currentPopupControlExtender.Commit(DirectCast(sender, Calendar).SelectedDate)
End Sub

Is this what you mean? I will try it tomorrow!

Use

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).TargetControlID
to find the TargetControlID of the PopupControlExtender that caused the panel to pop up. In other words, what textbox is the target of the PopupControlExtender.
 
Is that what you are looking for? 

Matt you are the man!

Protected

Sub Calender_SelectionChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(

Me).Commit(DirectCast(sender, Calendar).SelectedDate)EndSub

This work like a charme! I could use the Same "DatePickerPanel" on my page many times without duplicate code. Just add a Extender to the textbox and I'm done! Fine!

Thanks again for sharing this!


I am not sure that this actually works. I mean, the commit on the proxy works, but if I try to retrieve the value of TargetControlID from AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).TargetControlID, it is null (which sense since what is returned from the getproxy method is an empty popupcontrolextender)

Is there any way to retrieve this information? I am trying to set the value of two textboxes, each based on the other and another arbittrary value...

i.e. - i would like my code to be soomething like:

AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).Commit(calendar1.selecteddate.tostring())

select case AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page).TargetControlID

case "text1"

text2.text=format(calendar1.selecteddate.addmonths(arbitrary value),"MM/dd/yyyy")

case "text2"

text1.text=format(calendar1.selecteddate.addmonths(-1*arbitrary value),"MM/dd/yyyy")

end select


Could you pleaseopen a work item to report and track this issue. Thank you!

Multiple Popups using popcontrol extender

In the previous version of the ajax control toolkit I could reference multiply popups with one control. Ie on the page I have one calendar and 10 different textboxs which call popup the same calendar control. This would then run the selection changed code for the calendar and commit the date to which ever control had opened the popup. ie

ProtectedSub Date_Selector_SelectionChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Date_Selector.SelectionChanged

Date_Popup.Commit(Date_Selector.SelectedDate.ToShortDateString)

EndSub

However with the new version of the toolkit you have to have a different popup for each textbox. So when it goes into the date selector section how do I chosse the right popup to send the data back to.

I think the test case in ToolkitTests\Manual\Repeater.aspx shows how to do this the new way.

I had asimilar problemTed Glaza helped me solve. I have two textboxes with a popupcontrolextender attached to each, both of which call a single calendar, cal1. Some code snippits:

Code behind:

Protected Sub Cal1_SelectionChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Cal1.SelectionChangedDim tmppceAs AjaxControlToolkit.PopupControlExtender tmppce = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page) tmppce.Commit(Cal1.SelectedDate)End Sub

Declaration on the top of the .aspx page:

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
 
Everything works as expected. One thing to note, I'm running a self-compiled version of the toolkit - 9854. 

Multiple rating controls on one page malfunction

Hi,

When I put multiple rating controls on a page, only the first one works. The others act as if they has set ReadOnly = true. I've tried putting them on different pages, inside different update panels, inside the same update panel, outside update panels, setting ReadOnly = false for each one, setting the same OnChanged function, setting different OnChanged functions. Same thing every time. The first one works just fine and calls its OnChanged function. All the rest don't respond to mouseOver, and don't call their OnChanged. But their 1-5 tooltips do pop up, so they are breathing. Please help!

Any thoughts? Am I the only one this happens to? I'm new to ajax, so please point out the obvious...

I have the Script Manager on a master page. I set the .css to the one given in AjaxControlToolkit\SampleWebSite for simplicity. I also tacked ajax onto this project by copying web.config info ala joe's video- did I maybe miss something there?

Here's the code-

<asp:UpdatePanel id="upFilter1" runat="server">
<contenttemplate>
<cc1:Rating ID="rateFilter1" runat="server"
BehaviorID="RatingBehavior1"
CurrentRating="2"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="ContentFilterChanged"
style="float: left;" Height="6px" Width="65px" />
</contenttemplate>
</asp:UpdatePanel
<asp:UpdatePanel id="upFilter2" runat="server">
<contenttemplate>
<cc1:Rating ID="rateFilter2" runat="server"
BehaviorID="RatingBehavior1"
CurrentRating="2"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="ContentFilterChanged1"
style="float: left;" Height="6px" Width="65px" ReadOnly=false />
</contenttemplate>
</asp:UpdatePanel>


Again, first one works fine, second one doesn't respond.


I think it's because your BehaviorID IDs are the same. I'm having the same problem, but I'm generating my Ratings in a while loop, so cannot change them.


Anyone got any idea how I give each Rating control a unique BehaviorID?


Yep, that did it. It works with the basic appearances- now to hook them up to actually function. If it changes the functionality I'll check back in.

What's wrong with the loop? Can't you just set

NextRating.BehaviorID = NextID

NextID += 1



I've since found that you don't use while loops to output multiple rows of returned data anymore. The new method is to use an ASP Repeater and bind it to a dataTable. This magically sorts the IDs out for you by itself.

multiple ScriptManagers on a page

hi there; i've created the following page:

<%@dotnet.itags.org.PageLanguage="VB"MaintainScrollPositionOnPostback="true"AutoEventWireup="true"EnableEventValidation="false" %>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN"> <htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Welcome</title>

<scriptlanguage="VB"runat="server">

ProtectedSub RedirectUser(ByVal senderAs System.Object,ByVal eAs System.EventArgs)

Dim tempID = ddlTemp.SelectedItem.Value

Response.Redirect("default.aspx?tempID=" & tempID)

EndSub

</script>

</head>

<body>

<formid="frm"defaultfocus="txtTemp"runat="server">

<atlas:ScriptManagerID="ScriptManager1"runat="server"/>

<divclass="index"> <center>

<tablewidth="100%"height="100%"border="0"cellpadding="0"cellspacing="0">

<tr>

<td>

<divstyle="width:615px; text-align:left;">

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server">

<atlasToolkit:CascadingDropDownPropertiesLoadingText="Loading"Category="B"TargetControlID="ddlB"

ServiceMethod="GetB"ServicePath="WebService.asmx"PromptText="Please select"/>

<atlasToolkit:CascadingDropDownPropertiesCategory="A"TargetControlID="ddlA"

ParentControlID="ddlB"LoadingText="Loading"ServiceMethod="GetA"ServicePath="WebService.asmx"

PromptText="Please select"/>

</atlasToolkit:CascadingDropDown>

<asp:DropDownListID="ddlB"runat="server"/>

<asp:DropDownListID="ddlA"AutoPostBack="true"OnSelectedIndexChanged="RedirectUser"runat="server"/>

<divstyle="margin-top:25px;">

<asp:TextBoxID="txtTemp"runat="server"></asp:TextBox>

<asp:ButtonID="cmdFindTemp"CssClass="submit"UseSubmitBehavior="false"OnClientClick="this.disabled = true; this.value = 'Submitting...';"runat="server"PostBackUrl="default.aspx"Text="Go!"/>

<atlas:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server">

<atlas:AutoCompletePropertiesServicePath="WebService.asmx"ServiceMethod="GetTemp"TargetControlID="txtTemp"Enabled="true"MinimumPrefixLength="1"/></atlas:AutoCompleteExtender>

</div>

</div>

</td>

</tr>

</table>

</center>

</div>

</form> </body>

</html>

this page basically displays a couple of dropdown lists, a textbox and a submit button.

as you can see, i'm using the atlas control and the atlas toolkit control.

to make the controls function, i'm using the atlas:Scriptmanager.

using asp:scriptmanager (instead of an atlas:Scriptmanager) causes my page to crash with the following error message:

Extender controls require a ScriptManager to be present on the page.
Parameter name: scriptManager

what's worse is that if i try to add an ajaxToolkit control, such as:

<ajaxToolkit:TextBoxWatermarkExtenderID="TextBoxWatermarkExtender1"runat="server"TargetControlID="txtTemp"WatermarkText="Type Name Here"WatermarkCssClass="watermarked"></ajaxToolkit:TextBoxWatermarkExtender>

then i get the following error:

The control with ID 'TextBoxWatermarkExtender1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

well, the atlas:ScriptManager is before it and, again, i still get an error if i try using the asp:ScriptManager.

my question is, how many different scriptmanager's are there and what can i use that cover's all controls (i.e. ajax, ajaxToolbarKit, atlasToolbarKit)

thanks all.

Hi Chubbs,

Your problem is caused by the confilict between Atlas(previous version of Asp.Net Ajax Extension) and Asp.Net Ajax Extension. Ajax ControlToolkit works depend on Asp.Net Ajax Extension 1.0. So why not convert your application from "Atals" to "Asp.Net AJAX RTM" since it is more powerful and stable. It is recommended to update your Asp.Net Ajax Extension and Ajax ControlToolkit to the latest version.

Here is the way: http://ajax.asp.net/documentation/Migration_Guide_CTP_to_RTM.aspx

By can download the lastest released version here:http://ajax.asp.net/downloads/default.aspx?tabid=47

Hope it helps.


hi, jonathan; thanks for the response.

well, it took me several hours to tweak and work out the ensuing glitches, but it finally paid off. much cleaner now.

anyway, for the benefit of those who have the same issue, i will post my final working code.

basically, i have 2 cascading dropdowns that each receive their data from a database.

DROPDOWN.ASPX

======================================

<%@.PageLanguage="VB"MaintainScrollPositionOnPostback="true"AutoEventWireup="true"EnableEventValidation="false" %>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Cascading Drop Down</title>

<scriptlanguage="VB"runat="server">

</script>

<linkhref="styles.css"rel="stylesheet"type="text/css"/>

</head>

<bodyclass="index">

<formid="frmIndex"defaultfocus="txtCompany"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server"/>

<divid="index">

<center>

<tablewidth="100%"height="100%"border="0"cellpadding="0"cellspacing="0">

<tr>

<td>

<divstyle="width:630px; text-align:right;">

<ajaxToolkit:CascadingDropDown

LoadingText="Loading Provinces"

Category="Province"

ID="CascadingDropDown1"

TargetControlID="ddlProvince"

ServiceMethod="GetProvinces"

ServicePath="WebService.asmx"

PromptText="Please select a province"

runat="server"/>

<ajaxToolkit:CascadingDropDown

LoadingText="Loading Cities"

ParentControlID="ddlProvince"

Category="City"

ID="CascadingDropDown2"

TargetControlID="ddlCity"

ServiceMethod="GetCities"

ServicePath="WebService.asmx"

PromptText="Please select a city"

runat="server"/>

<asp:DropDownListID="ddlProvince"runat="server"/>

<asp:DropDownListID="ddlCity"AutoPostBack="true"OnSelectedIndexChanged="RedirectUser"runat="server"/>

</div>

</td></tr>

</table>

</center>

</div>

</form>

</body>

</html>

WEBSERVICE.VB

======================================

Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports System.Collections.Generic

Imports AjaxControlToolkit

Imports System.Data

Imports System.Data.SqlClient

Imports System.Collections

Imports System.Collections.Specialized<WebService(Namespace:="http://tempuri.org")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

<System.Web.Script.Services.ScriptService()> _

PublicClass WebServiceInherits System.Web.Services.WebService

<WebMethod()> _

PublicFunction GetProvinces(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As AjaxControlToolkit.CascadingDropDownNameValue()

Dim valuesAsNew System.Collections.Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

Dim myDatasetAs DataSet

myDataset = HttpContext.Current.Cache("tblProvince")

If myDatasetIsNothingThen

Dim myConnectionAsNew SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)

Dim myCommandAsNew SqlCommand("SELECT * FROM tblProvince", myConnection)

Dim myAdapterAsNew SqlDataAdapter(myCommand)

myDataset =New DataSet

myAdapter.Fill(myDataset)

HttpContext.Current.Cache.Insert("tblProvince", myDataset)

Else

myDataset =CType(HttpContext.Current.Cache("tblProvince"), DataSet)

EndIf

ForEach rowAs DataRowIn myDataset.Tables(0).Rows

values.Add(New CascadingDropDownNameValue(row("fldProvince"), row("fldProvinceID")))

Next

Return values.ToArray

EndFunction

<WebMethod()> _

PublicFunction GetCities(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()

Dim kvAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)

IfNot (kv.ContainsKey("Province"))Then

ReturnNothing

EndIf

Dim valuesAsNew System.Collections.Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

Dim myConnectionAsNew SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)

Dim strSQLAsString ="SELECT * FROM tblCity WHERE (tblCity.fldProvinceID='" & kv("Province") &"')"

Dim myCommandAsNew SqlCommand(strSQL, myConnection)

Dim myAdapterAsNew SqlDataAdapter(myCommand)

Dim myDatasetAsNew DataSet

myAdapter.Fill(myDataset)

ForEach rowAs DataRowIn myDataset.Tables(0).Rows

values.Add(New CascadingDropDownNameValue(row("fldCity"), row("fldCityID")))

Next

Return values.ToArrayEndFunction

EndClass

WEB.CONFIG

======================================

<?xmlversion="1.0"?>

<configuration>

<configSections>

<sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/>

<sectionGroupname="webServices"type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="Everywhere" />

<sectionname="profileService"type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication" />

<sectionname="authenticationService"type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication" />

</sectionGroup>

</sectionGroup>

</sectionGroup>

</configSections>

<connectionStrings>

<addname="myConnectionString"connectionString="Data Source={SQLServer};Server=yourServer;Database=yourDatabase;Uid=yourID;Pwd=yourPassword;"/>

</connectionStrings>

<system.web>

<pages>

<controls>

<addnamespace="System.Web.UI"tagPrefix="asp"assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addnamespace="AjaxControlToolkit"assembly="AjaxControlToolkit"tagPrefix="ajaxToolkit"/>

<addnamespace="AtlasControlToolkit"assembly="AtlasControlToolkit"tagPrefix="atlasToolkit"/>

<addnamespace="System.Data"tagPrefix="asp"/>

<addnamespace="System.Data.SQLClient"tagPrefix="asp"/>

</controls></pages>

<compilationdebug="true">

<buildProviders>

<addextension=".asbx"type="Microsoft.Web.Services.BridgeBuildProvider"/>

</buildProviders>

<assemblies>

<addassembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

<addassembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

</assemblies>

</compilation>

<httpHandlers>

<removeverb="*"path="*.asmx"/>

<addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/></httpHandlers>

<customErrorsmode="Off"/>

<httpModules>

<addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</httpModules>

</system.web>

<system.web.extensions>

<scripting>

<webServices>

<!-- Uncomment this line to customize maxJsonLength and add a custom converter-->

<!--

<jsonSerialization maxJsonLength="500">

<converters>

<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>

</converters>

</jsonSerialization>

-->

<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate.-->

<!--

<authenticationService enabled="true" requireSSL = "true|false"/>

--><!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved

and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and

writeAccessProperties attributes.-->

<!--

<profileService enabled="true"

readAccessProperties="propertyname1,propertyname2"

writeAccessProperties="propertyname1,propertyname2" />

-->

</webServices>

</scripting></system.web.extensions>

<system.webServer>

<validationvalidateIntegratedModeConfiguration="false"/>

<modules>

<addname="ScriptModule"preCondition="integratedMode"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</modules>

<handlers>

<removename="WebServiceHandlerFactory-ISAPI-2.0"/>

<addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

</handlers>

</system.webServer>

</configuration>

Well, there it is in it's entirety. Hopefully this will help someone get up and running with this control in the future.

Good luck!

Multiple Timers and Multiple UpdatePanels

I am creating a page with many different server controls that each need to automatically refresh independently. I want the developer to be able to specify the refresh time, so I am exposing that as a property of the control. The problem is, whenever the first timer ticks, all the other timers reset (and the label control in each UpdatePanel updates with the current time) even though they are on different intervals. It acts like all the UpdatePanels are posting back, but I know the tick event is only firing on the first timer (the one with the lowest interval). Any ideas as to what's happening here or what I'm doing wrong?

Here is my (raw, not refactored) code (CreateChildControls method):

If AutoUpdateThen Dim panelAs UpdatePanel =New UpdatePanel()Dim progressAs UpdateProgress =New UpdateProgress() _label =New WebControls.Label()Dim timerAs Timer =New System.Web.UI.Timer() panel.ID =Me.ID +"_UpdatePanel" panel.ChildrenAsTriggers =True panel.UpdateMode = UpdatePanelUpdateMode.Conditional timer.ID = panel.ID +"_RefreshTimer"#If DEBUG Then timer.Interval = IIf(RefreshSeconds <> 0, RefreshSeconds, _refreshMinutes)#Else timer.Interval = _refreshMinutes#End If AddHandler timer.Tick,AddressOf OnTimerTick panel.ContentTemplateContainer.Controls.Add(timer) _label.Text =String.Format("Updated at: {0}", DateTime.Now) panel.ContentTemplateContainer.Controls.Add(control) panel.ContentTemplateContainer.Controls.Add(_label) control = panelEnd If
I've also tried creating the timers outside the UpdatePanels and adding an ASyncPostBack trigger on the Tick event of each timer like so:
 
If AutoUpdateThen Dim panelAs UpdatePanel =New UpdatePanel()Dim progressAs UpdateProgress =New UpdateProgress()Dim timerTriggerAs New AsyncPostBackTrigger() _label =New WebControls.Label()Dim timerAs Timer =New System.Web.UI.Timer() panel.ID =Me.ID +"_UpdatePanel" panel.ChildrenAsTriggers =False panel.UpdateMode = UpdatePanelUpdateMode.Conditional timer.ID = panel.ID +"_RefreshTimer"#If DEBUG Then timer.Interval = IIf(RefreshSeconds <> 0, RefreshSeconds, _refreshMinutes)#Else timer.Interval = _refreshMinutes#End If timerTrigger.ControlID = timer.ID timerTrigger.EventName ="Tick" Controls.Add(timer) panel.Triggers.Add(timerTrigger) _label.Text =String.Format("Updated at: {0}", DateTime.Now) panel.ContentTemplateContainer.Controls.Add(control) panel.ContentTemplateContainer.Controls.Add(_label) control = panelEnd If
Thanks! 

D'oh!


A detail I had failed to mention previously was that these update panels are contained within a surrounding update panel. This panel was set to UpdateMode = Always, which was causing all of the UpdatePanels inside of it to automatically update. I set it to conditional and it seems to work fine now.

-Joe

Multiple UCs on a page

On my page I have two User Controls. One, UC1, has a DropDownList. The other one, UC2, is a list that gets data from a SqlDataSource (datasourcetype=strored procedure), by Repeater.

Whenever the ddl in UC1 is changed, it triggers a function that puts a log record into the database from which UC2 gets the data.

I need the new log record to appear immediately after the selected index of ddl is changed, but it only appears after I refresh the page.

I can't create any triggers for the UpdatePanel of UC1, because the controls are in different UCs.

I tried to use delegates and events, but unsuccessful. My knowledge in that area is limited.

You should be able to use triggers for the update panel even though they are different controls.
Can you post your code?
You can also just refresh the page in code...


Make sure they are both in updatepanels, and set both toUpdateMode="Always". Then, when one updates, the other automatically updates.

Multiple Update Panels - Postback on Panel A cancels Postback on Panel B

Hi,

I have a page with multiple Update Panels. Each panel has a button as a trigger.

When the first button is clicked it causes the first panel to update (as you'd expect), however if while this panel is being updated, the second button is clicked to update the second panel, the first request is cancelled, and the first panel is never updated.

Is this the expected behavior? Are there any work arounds?

Many Thanks,
Ady

Yes, unfortunately it is by design. Only the last UpdatePanel requets will be considered and prior reuests discarded.

Hmm, thats a shame.

I wonder if there is a way to intercept the request, and effectively queue it until the first request completes.

Time to start playing.


This tutorial might help you get started:http://ajax.asp.net/docs/tutorials/ExclusiveAsyncPostback.aspx.

multiple update panels

hi every one..

i am using multiple update panels (more than 10) on a web page in my Ajax enabled asp.net website.

I would like to know whether it is feasible to use so many Update panels in a single form (one for each control which will go to server), or there is a possibility that i will face some problem due to it.

Any alternatives are also welcome.

thanx,

viraj

hello.

using several updatepanels might be a good approach if the zones wrapped by the panels should be refresed independently. in this case, setting the updatemode to conditional will result in reducing the size of the response returned from the server side. I'm not sure if there's any recommendation in the number of itens UpdatePanels that should be used in a page.


thanx...

Multiple Update Panels

Evening all,

As part of a larger development, I had an idea to develop a quiz using two update panels on one page. My idea was that the first update panel would have two dropdown lists binded to a database. Dropdown list 1 would hold the question. When the user selected an entry from the list, the 2nd dropdown list would populate with the answer. I added a delay using theSelectedIndexChanged event as follows:

Protected

Sub DropDownList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)

System.Threading.Thread.Sleep(10000)

EndSub

I also added an updateProgress control to displayTime is running out.

Now the 2nd update panel had a simple text field and a button. The idea was that the user would try to beat the controls in updatePanel1 displaying the result. The user would enter their answer and click submit. This would then be compared to the actual write answer and a score would be recorded. I guess you have enough here to get my drift.

Now the big problem with this is that whilst updatePanel1 is updating, any event in updatePanel2 throws an error along the lines of: "Invalid Postback or callback argument".

From what I can gather from the complete error message, some sort of validation has been actioned and these simultaneous callbacks/postbacks can't happen. Is this just the way it is or is their a way around this. The error message makes reference to setting a pages element in the config file with the attribute "enableEventValidation=True". Now this stops me getting the error message in my page, but the lists in updatePanel1 don't display the right data.

Any tips on this or idea's on how to achieve my original concept would be hugely appreciated. I have included the relevant code below.

Kind regards

Mike

<

asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering=true/><div><asp:UpdatePanelID="UpdatePanel1"runat="server"RenderMode="Inline"UpdateMode="Conditional"><ContentTemplate><asp:DropDownListID="DropDownList1"runat="server"DataSourceID="AccessDataSource1"DataTextField="question"DataValueField="qID"AutoPostBack=TrueOnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList><asp:DropDownListID="DropDownList2"runat="server"DataSourceID="AccessDataSource2"DataTextField="answer"DataValueField="answer"OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"AutoPostBack="True"></asp:DropDownList><asp:AccessDataSourceID="AccessDataSource2"runat="server"DataFile="~/App_Data/quiz.mdb"SelectCommand="SELECT * FROM [answer] WHERE ([qID] = ?)"><SelectParameters><asp:ControlParameterControlID="DropDownList1"Name="qID"PropertyName="SelectedValue"Type="Int32"/></SelectParameters></asp:AccessDataSource><asp:AccessDataSourceID="AccessDataSource1"runat="server"DataFile="~/App_Data/quiz.mdb"SelectCommand="SELECT * FROM [questions]"></asp:AccessDataSource><asp:UpdateProgressID="UpdateProgress1"runat="server"DisplayAfter="0"><ProgressTemplate>

Hurry up.......

</ProgressTemplate></asp:UpdateProgress></ContentTemplate>

</asp:UpdatePanel><br/><hr/><asp:UpdatePanelID="UpdatePanel2"runat="server"RenderMode="Inline"ChildrenAsTriggers=falseUpdateMode="Conditional">

<ContentTemplate>

<asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"OnDataBinding="Button1_DataBinding">

</asp:button>

<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox></ContentTemplate></asp:UpdatePanel>

I seem to have solved the initial error message problem by nesting the updatePanels as opposed to having 2 independent panels. I'll continue with this and see how I get on.

Any tips from anybody else would be hugely appreciated.

Kin Regards

Mike

Multiple Update Panel Animation Extenders on one page

Hi there!

I'm developing a web user control that contains an Update Panel and uses an Update Panel Animation Extender.
The animation is quite simple: while the panel is updating, it fades out the contents of the update panel and fades in the "please wait while processing..." message...then the animation reverses the process when the panel is Updated. The animation works quite nicely.

The problem I'm facing is when I have more than one of these web user controls on the page at a time (I'm using 8 of these on one page at a time).
If one web user control's update panel does an asynchronous postback, all of the animations are run!

Does anyone know how to get around this problem?

Thanks in advance,

-Frinny

Hi,

Would you please provide with any code of ypur usercontrol?

Or create a simple repro of this problem?

Thanks,


I forgot that I had posted this question.
I found the solution to my problem a while ago.

The problem I was describing is not actually a problem, it is how the UpdatePanelAnimationExtender works.

Anyways, to get around this problem I ended up using regular Animations instead of the UpdatePanelAnimationExtender.

Cheers!

Multiple update panels: content disappears when modalpopup is used

Hello there,

I'm experiencing a rather annoying issue at the moment. I'm working on a webapplication, which contains quite a big page. This page contains multiple updatepanels, which in their turn contain dropdownlists/checkboxes. The page also uses a TextboxWatermarkExtender on one textbox control, and a ModalPopup which is shown conditionally by calling .Show() from the codebehind.

The ModalPopupExtender and TextboxWatermarkExtender are not on an updatepanel or anything.

Everything seems to work as it should, but I'm having a rather annoying cosmetic issue: at the moment the modalpopup is shown on my page, all the content of the updatepanels dissapears: none of the dropdownlistboxes are visible anymore!

Something weird also happens when I do any action in any of the updatepanels: when I do this, the TextboxWatermarkExtender seems to "refresh" its text (you see the text "flash").

I'm thinking these issues might be connected somehow... Has anyone got any idea on how to solve this issue, or has anyone else ran into this?

I took a few screnshots to illustrate the problem.

This is how the page looks without the modal popup:

This is with the modal popul:

As you can see, all the dropdownboxes have disappeared. Also, I noticed not only the dropdownboxes in updatepanels diasppear, but those that aren't also disappear.

Any ideas/suggestions? Tnx!


No-one? :( I've been looking all over the internet for this, but I can't seem to find anyone having the same issue. I do find issues with dropdownboxes floating "on top of" a layer when using Internet Explorer, but that's not the problem I have here... Also, I noticed this behaviour doesn't appear in Firefox: everything looks ok when using that browser...

My DDL(s) also disapeer with modal popup!!

And I had another problem with them when the modal popup causes a postback.

So I solved that by wrapping my DDL in another update panel... (with updatemode="always", dunno if that was necessary...)

But it seems to be working now...


And another update: I installed IE7 recently, and in that browser, the problem seems to be solved: the dropdownboxes don't disappear anymore.

So, this really seems to be an IE6-browser issue. I tried putting the ddl's in updatepanels (some of them already were), but that didn't help...

Browser-specific issues... gotta hate 'em ;-)

Multiple Update Panels Problem

hello!

I have 4 update panels on my page, 2 of which I used to load slow loading data displayed in gridviews. I wanted to display the layout of the page before it loads the data (showing a small loading graphic in the updated divs) so the user does not think the page is stuck. To do this, I used two timer controls with interval 1 so that once the page is loaded, the timers will tick and the data will be fetched and bound to the gridviews. I am facing a few problems:

1. One gridview's data is slower than the other, and instead of the faster one displaying first then the slower one, it waits until the slower one fetches its data and then they are both displayed at the same time.

2. I have another gridview that uses a timer (interval 6000) and the timer_tick sub for it scrolls through the gridview pages. But the timer does not start ticking until the other two gridviews load.

3. The 4th update panel has a next and previous button displaying news articles. The buttons do not cause anything until the two slow panels load (just like the gridview in point 2 above).


Is there another way I can trigger the two slow gridviews to load AFTER the page loads and displays something for the user? And why do the other update panels wait for these two slow panels to finish before letting the user update them?

Your speedy support is greatly appreciated!

Make sure that you set UpdateMode="Conditional" on all the update panels to be able to update them individually. Otherwise they will all update their contents on postback.

Call UpdatePanel.Update() on the ones that should be updated.


Try delay loading your update panel like the following:
http://mattberseth.com/blog/2007/07/delay_load_an_updatepanel.html


Wow thanks for the replies! I'll try this stuff out and let you know!


OK I tried Matt Berseth's delay load approach. For some reason, the __doPostBack method does not force the button click method to be invoked. As a result, the two gridviews do not load.

<script type="text/javascript" language=javascript>
var _isInitialLoad = true;

function pageLoad(sender, args){
if(_isInitialLoad){
_isInitialLoad = false;
// simulate a button click by forcing the postback
// causing the updatepanel to update
__doPostBack("<%= me.btnHidden.ClientID %>","");
}
}
</script>

<asp:button id="btnHidden" runat="server" style="display:none;" OnClick="btnHidden_Click" />

<asp:UpdatePanel id="UpdatePanel4" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnHidden" Eventname="Click"></asp:AsyncPostBackTrigger>
</Triggers>

// the content of this panel is a gridview.. the btnHidden_Click sub binds the data to the gridview..

Any ideas?


Just an update.. I changed the dopostback call from

__doPostBack("<%= me.btnHidden.ClientID %>","")

to

__doPostBack("<%= me.btnHidden.UniqueID %>","")

that worked but the updateprogress control did not appear (the screen looked like it finished loading and then suddenly the gridviews got displayed).

I really appreciate your assistance!


Hi,

I've created a user control that I'm trying to use to delay content loading on a page for long running controls.check out this:Delaying Content Load using Timer and UpdatePanel

Best Regards


Hey man thanks for the update but the link refers to this site: http://www.null.com/t/1127147.aspx

which displays nothing! ;-) can you plz update with the proper link so i can test?

thx for ur help!


Thanks for the control Jin-Yu,

Here's the url
http://forums.asp.net/t/1127147.aspx

Multiple Update Panels not exactly asynchronous

Hi,

I'm having trouble getting a page with 2 update panels to update themselves asynchronously. It appears, the update inside of one update panel is canceled as soon as the other update panel begins an update.

I want to be able to click a button inside of an update panel. Then, while that panel is updating, click on another button inside of another update panel without canceling the first update.

Not sure if this makes sense or if it's possible, but below is some code demonstrating the issue. When you try to click both buttons, the update of the first button is cancelled.

1<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>23<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>4<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">5<html xmlns="http://www.w3.org/1999/xhtml">6<head runat="server">7 <title>Untitled Page</title>8</head>9<body>10 <form id="form1" runat="server">11 <asp:ScriptManager ID="ScriptManager1" runat="server" />12 <div>13 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">14 <ContentTemplate>15 <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">16 <ProgressTemplate>17 Updating UpdatePanel1...18 </ProgressTemplate>19 </asp:UpdateProgress>20 <asp:Label ID="lblUpdate1" runat="server"></asp:Label>21 <asp:Button ID="btnUpdate1" runat="server" OnClick="Button1_Click" Text="Update 1" />22 </ContentTemplate>23 <Triggers>24 <asp:AsyncPostBackTrigger ControlID="btnUpdate1" EventName="Click" />25 </Triggers>26 </asp:UpdatePanel>27 </div>28 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">29 <ContentTemplate>30 <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel2">31 <ProgressTemplate>32 Updating UpdatePanel2...33 </ProgressTemplate>34 </asp:UpdateProgress>35 <asp:Label ID="lblUpdate2" runat="server"></asp:Label>36 <asp:Button ID="btnUpdate2" runat="server" OnClick="btnUpdate2_Click" Text="Update 2" />37 </ContentTemplate>38 <Triggers>39 <asp:AsyncPostBackTrigger ControlID="btnUpdate2" EventName="Click" />40 </Triggers>41 </asp:UpdatePanel>42 </form>43</body>44</html>45

1using System;2using System.Data;3using System.Configuration;4using System.Web;5using System.Web.Security;6using System.Web.UI;7using System.Web.UI.WebControls;8using System.Web.UI.WebControls.WebParts;9using System.Web.UI.HtmlControls;10using System.Threading;1112public partialclass _Default : System.Web.UI.Page13{14protected void Page_Load(object sender, EventArgs e)15 {1617 }1819protected void Button1_Click(object sender, EventArgs e)20 {21 Thread.Sleep(5000);22 lblUpdate1.Text = DateTime.Now.ToString();23 }24protected void btnUpdate2_Click(object sender, EventArgs e)25 {26 Thread.Sleep(5000);27 lblUpdate2.Text = DateTime.Now.ToString();28 }29}

Take a look at this post:http://forums.asp.net/t/1117212.aspx and this one:http://forums.asp.net/t/1108522.aspx

Basically, you can only have 1 asynchronous request at a time with UpdatePanels.

-Damien


See the link it will solve your problem

http://forums.asp.net/t/1108522.aspx


Awesome. That works great for buttons.

Any idea how to do the same thing for other events? Like a GridView Sorting or SelectedIndexChanged event?


Checkout this posthttp://geekswithblogs.net/rashid/archive/2007/08/08/Asp.net-Ajax-UpdatePanel-Simultaneous-Update--A-Remedy.aspx


KaziManzurRashid:

Checkout this posthttp://geekswithblogs.net/rashid/archive/2007/08/08/Asp.net-Ajax-UpdatePanel-Simultaneous-Update--A-Remedy.aspx

Thanks Kazi. That works, but for some reason it does not work if I use a MasterPage. I've tried putting the scriptmanager in the masterpage and in the webform using that master page and it doesn't work either way. Any ideas why?

EDIT: BTW, It appears the _doPostBack() method of the prm instance is not working for elements inside of a masterpage. Not sure what I'm doing wrong.


I was able to fix my MasterPage problem by making the changes suggested by the 2 comments in the blog.

I also made the following change to the endRequest() function in order to support GridView postbacks:

1function endRequest(sender, args)2 {3 //Check if we have a pending call4 if (_callQueue.length > 0)5 {6 //Get the first item from the call queue and setting it7 //as current executing item8 _executingElement = Array.dequeue(_callQueue);9 var _element = _executingElement[0];10 var _eventArg = _executingElement[1];1112 //Now Post the from which will also fire the initializeRequest13 if(_element.name != null)14 _prm._doPostBack(_element.name, _eventArg);15 else16 _prm._doPostBack(_element.id.replace(/_/g,"$"), _eventArg);17 }18 }

So basically if the executingElement does not have a name set, I create it by replacing the '_' characters in the id with '$' characters (not sure if this is ok, but it's working).

My final problem: The UpdateProgress control is not displaying for the queued requests. Any idea how to make this work??

Thanks,

Fred

multiple update panels each with a timer

I have a very simple page. It has 1 script manager and 2 update panels. Each update panel has a label and a timer. the timers are set 1 second and each simply updates the label with the current time. The first timer works and displays the time. The second never fires. Any one have any ideas? Here is the page...

<%

@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="WebApplication1._Default" %>

<%

@dotnet.itags.org.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><div><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>

</div> <asp:UpdatePanelID="UpdatePanelFirst"runat="server"><ContentTemplate><asp:TimerID="TimerFirst"runat="server"Interval="1000"OnTick="TimerFirst_Tick"></asp:Timer><asp:LabelID="LabelFirst"runat="server"></asp:Label></ContentTemplate></asp:UpdatePanel><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:TimerID="Timer1"runat="server"Interval="1000"OnTick="Timer1_Tick"></asp:Timer><asp:LabelID="Label1"runat="server"Text="Label"></asp:Label></ContentTemplate></asp:UpdatePanel></form>

</

body>

</

html>

and the code behind.

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;

namespace

WebApplication1

{

publicpartialclass_Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protected

void Timer1_Tick(object sender,EventArgs e)

{

Label1.Text =

DateTime.Now.ToShortTimeString();

}

protectedvoid TimerFirst_Tick(object sender,EventArgs e)

{

LabelFirst.Text =

DateTime.Now.ToLongTimeString();

}

}

}

I am not sure about your requirement. If you are trying to update both the labels at the same time one timer will do.

But if you want both the Timer ticks to work modify your code as follows:

protected

void Timer1_Tick(object sender,EventArgs e)

{

Timer1.Enabled =

false;

Timer2.Enabled =

true;

Label1.Text = System.

DateTime.Now.ToLongTimeString();

}

protectedvoid Timer2_Tick(object sender,EventArgs e)

{

Timer2.Enabled =

false;

Timer1.Enabled =

true ;

Label2.Text = System.

DateTime.Now.ToLongTimeString();

}

Multiple Update Panels & Control Events

Thankfully i've been able to re-create this issue but i'm still not entirely sure why it happens as it does. I've created a page with two update panels, inside of each is a label and a button. Each label is set to the current date when the labels PreRender event fires. The first time this loads, each event fires at pretty much the same time. As expected if i press either of the buttons, both label PreRender events fire and update the corresponding label. However If i set the update mode to conditional on the updatepanel, both labels PreRender events fire but only the one which shares the update panel with the pressed button has the UI updated. In this trivial example thats not too much of a problem, however when I'm loading in a dataset in one of the panels, i dont want the data being re-loaded in each time a different update panel posts back. Thanks in advance, Matt Here's my trivial example HTML and C# c#
protected void Page_Load(object sender, EventArgs e) { }protected void Label1_PreRender(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); }protected void Label2_PreRender(object sender, EventArgs e) { Label2.Text = DateTime.Now.ToString(); }protected void Button2_Click(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) { }
<asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server" OnPreRender="Label2_PreRender" Text="Label"></asp:Label> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit 2" /> </ContentTemplate> </asp:UpdatePanel> </div> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" OnPreRender="Label1_PreRender" Text="Label"></asp:Label> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Submit One" /> </ContentTemplate> </asp:UpdatePanel>

This is by design. When you have multiple UpdatePanels and each set to Conditional, UI updates only occur in that particular UpdatePanel. You can get more info about UpdatePanels in the docs:http://www.asp.net/AJAX/Documentation/Live/tutorials/UpdatePanelTutorials.aspx

For updating a label like you are, I would utilize PageMethods vs. and UpdatePanel anyway. You can mix the two technologies if you need to. Seehttp://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous for an excellent example and more information.

-Damien

Multiple UpdatePanels

I'm using multiple UpdatePanel on a page, i don't want all of them to get updated when one of them need to be updated.

when i make some action of a control insidr one of them, the whole updatepanels gets updated.

how can i work arround this?

Thanx

Hi

Simply set the option EnablePartialRendering of yor ScriptMangerControl to true and your updates Panel mode to Conditional

EnablePartialRendering="true"

Mode="Conditional"

Multiple UpdatePanel query

In my web application, on one page I'm having 4 UpdatePanel. All data corresponding to this UpdatePanel comes from database, so there is a substantial waiting time. When the page gets loaded, data for each UpdatePanel gets loaded 1 at a time.Can I load data for all sections asynchronously? Since this can help my application to reduce the loading time. Or it's not possible to start another request before the 1st one is complete?Any help will be appreciated.

Hi

I am not sure abt ur first issue but i think that in case you can do synchronization.

Tell me if you get any help regarding your blog..

Thanx


Please refer to this: http://forums.asp.net/t/1108522.aspx


Thanks for your reply. I have referred that post, before posting this query.

Can you provide me with some document if you have any.


To have a good understanding of the life cycle of async-request is helpful. Please refer to this for more information, http://ajax.asp.net/docs/overview/AJAXClientEvents.aspx

With the UpdatePanels, only one asynchronous request is handled at a time. This is intentional because these request include the ViewState on the page and make it almost impossible to keep it all in sync if multiple requests are occuring simultaneously. Raymond is correct in mentioning that you should get a good grasp of the life cycle that happens during these request - there is the asp.net page lifecycle, but there is also a client-side lifecycle. In short, become familiar with the PageRequestManager, this client-side object will grant you more control of what goes on during these ajax postbacks. Lastly, check out this sample to see how to work with the client-side events:http://weblogs.asp.net/davidbarkol/archive/2007/03/25/asp-net-ajax-client-side-event-viewer.aspx


Thanks Raymond and David for your suggestion.

Multiple UpdatePanel on page Issue. Please Help

Cannot unregister UpdatePanel with ID XXX since it was not registered with the ScriptManager.This might occur if the UpdatePanel was removed from the control tree and latter added again

Help me guyz. i am getting this error, and i wonder y.

let me explain you my scenario

-

i have a wizard control and on its steps; i have dropped a script manager + 2 update panels. the update panels contain user controls (.ascx pages). the user controls are simple gridviews with some business logic binded to them.

when i start my applicaiton, the page opens, and a big error is displayed, as above.

kindly update me on this issue. wiating for your reply

Regards

- mbakhan

try pulling the script manager out of the wizard step, and put it at the top of the page (before all other controls but keep it inside the <form runat="server"> tag.).

Let me know if that helps.

-Alan


Hi Alan, thanks for the reply,

but still keep it coming, need help Urgent

well i have tried this. but it wont help.

my page has a master page on it, so my scriptmanager is just under the asp:content tag, it still wont help.

i will try to put it on the master page.


If putting it in the masterpage doesnot work, then post your code, because I have a similar situation on a page that works fine.

-Alan


well when i make the display of sidebar false of the wizard control, i get this error.

without that it seems to work fine.

any suggestions for this.

i will make a test page of this scenario and send it to you. where shuld i email you ?

- Bassam


I guess I need a clerification of what you have on your page. You have a wizard with 2 steps with an updatepanel in each step? And you have moved the update panel to the masterpage? Let me know if I got it wrong, because I am going to try and get my page to die the way your does :).

-Alan


Hi there

well i am getting the same error which you have discussed about, and i am not able to understand what / how to get a fix round of it. :(

my scenario is that i have a user control, UC1. i will drop it in an UpdatePanel UP1 on a wizard control WC1 step page, on the Main .aspx page. like

WC1 contains UP1; UP1 contains UC1,

Now the interesting part is that i use this wizard as a multipurpose navigation system; (Editing some values and i the wizard sidebar display enabled, second for adding some values where the sidebar display disabled.) . When the sidebar display is disabled, i get this error...otherwise it works fine. i have tried almost all the clues in the book..but nothing seems to wrk that well..or maybe i am not that near..:(...just help me in it.

i have the script manager declared rite under the form tag on the master page, and all seems good / smooth to me, but still I WILL GET THIS ERROR :(.

please help me over this error. Waiting for your reply. [I hope this completely explains my scenario]

- Bassam

Multiple UpdatePanel issue request at a same time

Hi all,

I have a page contains more than one UpdatePanel with different triggers and I followed the method here to handle multiple requests:

http://ajax.asp.net/docs/tutorials/ExclusiveAsyncPostback.aspx

When one of the UpdatePanels has been triggered and refreshing, all the requests from other UpdatePanels in the page will be cancelled since prm.get_isInAsyncPostBack() returns true until the first request has been processed.

Are there any method to invoke multiple requests at the same time? Or else the user has to wait until the first request to be done before he/she can issue new requests with the other panels. I can accept the requests to be queued up and pending to be patched, but the PageRequestManager seems simply drops the previous or new requests depends on the implementation in the block:

if (prm.get_isInAsyncPostBack()) {
// drop new request or abort previous request
}

FYI, I found simliar post here:http://forums.asp.net/thread/1413005.aspx

Thank you.

HI Kylo,

I wondered the same thing. From all my reading, you can only send out one request at a time using the update panel. The only true asynchronous way to use asp.net AJAX is through web services. By default, the update seems to execute the latest request that was given and drop the previous.


Thanks for the reply, bebandit. In my case, I was converting a .NET 1.1 project to 2.0 to gain the benefit of easily adding ajax capabilities to the web application. UpdatePanel handles all ajax call, DOM manipulation and the UI rendering for me. If I have to write the client side web services call and UI refreshing HTML myself (not to mention to change some of the server side logic to web method as well), it would take too much development time and not worth to do in my business logic. Seem that I have to wait to see if there will be a truely "Asynchronous UpdatePanel" in the later release or I will look for the other AJAX libraries.


Thanks for the reply, bebandit. In my case, I was converting a .NET 1.1 project to 2.0 to gain the benefit of easily adding ajax capabilities to the web application. UpdatePanel handles all ajax call, DOM manipulation and the UI rendering for me. If I have to write the client side web services call and UI refreshing HTML myself (not to mention to change some of the server side logic to web method as well), it would take too much development time and not worth to do in my business logic. Seem that I have to wait to see if there will be a truely "Asynchronous UpdatePanel" in the future release or I will look for the other AJAX libraries.

Multiple UpdatePanels updated by single trigger -- bug or feature?

Hi, not sure if this has been discussed before but..

I'm running April CTP, and I have two UpdatePanels on my page. UpdatePanel1 includes a navbar with various LinkButtons, and the other UpdatePanel2 contains a GridView. I've added a ControlEventTrigger to UpdatePanel2 for the click event of the LinkButtons in UpdatePanel1. UpdatePanel1 has no triggers (I plan on adding triggers at a later time). The issue is, when I click a LinkButton from UpdatePanel1, it updates both UpdatePanels! I would like it to only update UpdatePanel2 as I thought it should, but maybe I am just not understanding the way UpdatePanels work.

I'm thinking the fact that UpdatePanel2 is using a Control Event from UpdatePanel1, this might be the cause of these problems. When I moved the LinkButtons out of UpdatePanel2, UpdatePanel1 was no longer updated. I've included the source code for the two UpdatePanels:

<atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional"> <ContentTemplate> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td><asp:LinkButton CssClass="navlink_selected" ID="homeLinkT" runat="server" OnClick="link_Click" CommandName="home" CommandArgument="1" >home</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="aboutLinkT" runat="server" OnClick="link_Click" CommandName="about" CommandArgument="2" >about</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="resumeLinkT" runat="server" OnClick="link_Click" CommandName="resume" CommandArgument="3" >resume</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="projectsLinkT" runat="server" OnClick="link_Click" CommandName="projects" CommandArgument="4" >projects</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="forumLinkT" runat="server" OnClick="link_Click" CommandName="forum" CommandArgument="5" >forum</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="contactLinkT" runat="server" OnClick="link_Click" CommandName="contact" CommandArgument="6" >contact</asp:LinkButton> </td> <td style="width:80px"> <atlas:UpdateProgress ID="up1" runat="server"> <ProgressTemplate> <asp:Image ID="Image2" runat="server" ImageUrl="~/images/Hourglass_iconsm.gif"/> </ProgressTemplate> </atlas:UpdateProgress> </td> </tr> </table> </ContentTemplate> </atlas:UpdatePanel> <atlas:UpdatePanel runat="server" ID="UpdatePanel2" Mode="Conditional"> <ContentTemplate> <asp:HiddenField ID="page_id" runat="server" Value="1" /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="page_id" DataSourceID="ObjectDataSource1" ShowHeader="False" GridLines="None" AutoGenerateEditButton="false" > <Columns> <asp:TemplateField> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Height="100%" Text='<%# Bind("page_content")%>' TextMode="MultiLine" Width="600px" Rows="10"></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("page_content")%>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="page_id" HeaderText="page_id" ReadOnly="True" SortExpression="page_id" Visible="False" /> </Columns> </asp:GridView> </ContentTemplate> <Triggers> <atlas:ControlEventTrigger ControlID="homeLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="aboutLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="resumeLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="projectsLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="forumLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="contactLinkT" EventName="Click" /> </Triggers> </atlas:UpdatePanel>

Anyone have any ideas?

Thanks,

Matt

This is not a bug, but the intended result.

Clicking a server control that causes a postback (i.e. a link button or a normal button) when that server control is contained within the ContentTemplate of an UpdatePanel will cause that UpdatePanel to update even if it is not explicitly defined as a trigger. UpdatePanel1 is updating for this reason and UpdatePanel2 is updating because the control is defined as a triggering event.

Ah, thanks for the clarification Joel!

Matt


So is there a way for getting around this? If I have a menu of links and I want some to be loaded into one updatepanel and some into another. Is this even do-able?

Thanks.