Showing posts with label updatepanel. Show all posts
Showing posts with label updatepanel. Show all posts

Wednesday, March 28, 2012

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 which one is actived javascript

Hi all,

Title says everthing actually. I need to find which update panel is updating at the moment for multiple update panel coding which in one update panel i have coded to update others on the server side conditionally. If i cant find which one is activated is it possible to find which one initiated the update will work too. Thanks

Hi.

You can use UpdateProgress and associated the update panel with AssociatedUpdatePanelID property .

Hopes that help.


If I understand you correctly, you want to know on the client which UpdatePanel(s) were just updated.

If that's right, then take a look at the PageLoaded event on the PageRequestManager:http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerPageLoadedEvent.aspx.

You'll get two parameters passed to your handler... the second is a PageLoadedEventArgs:http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageLoadedEventArgsClass/default.aspx.

You can use args.get_panelsUpdated() to get an array of <div> elements that were just updated during an async postback.


actually both answers are not what I'm looking for if i read correctly. First i don't have UpdateProgress i use an generic modal that's called all over the place with out caller information. Its a function that shows please wait message like pleasewait(true); or false soAssociatedUpdatePanelID wont work since i don't have one.

And for your suggestion if i read this right, it works right after the update is ended, I need it while its working so i know if i want to abort it or not. Since one of the update is crucial not to stop, one is not crucial. So when i give them option to stop it should only stop if its not crucial. (if that make sense)

Im not sure but im going to try to set an hidden field with a value right when the update starts but didnt have time to test this one yet.


So you're looking to see what control is causing the update? (As opposed to which panels will be updated.)


no no i am look looking for which update panel is getting updated but i need to know it before or while the server side is getting called, like lets say we have updatepanel1, panel2 and panel3

they all call pleasewait(true) function to start the please wait modal window

I show a cancel button here but i only want this cancel button to work for updatepanel1 so need is it the panel one activing the please wait or panel2 or 3, so using the info i can disable the cancel button.

I hope that make sense.


But from your first post, aren't you making the decision about which UpdatePanels to update on the server? If so, there's no way to know on the client which panels will be updated, since that hasn't been decided yet.

In general, even if you're not doing anything explicit on the server (just using Triggers), all you can know on the client is which control is posting back. You won't know until the postback finishes which panels actually get updated.


Steve Marx:

But from your first post, aren't you making the decision about which UpdatePanels to update on the server? If so, there's no way to know on the client which panels will be updated, since that hasn't been decided yet.

Thats ok, i tought it would be the same tooo. So is possible to tell the second part of my question

drewex:

If i cant find which one is activated is it possible to find which one initiated the update will work too

As long as i can find which one initiates the update i think i can make this work.


I'll add one more thing there are iframes that i use in this page which can call the please wait too. So i need to seperate those too. But if there is not updatepanel update initiated that means iframe called it. so i can give cancel option or not. I hope im making some sense.

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 vs single updatepanel

Hi,

Anybody got any information regarding the trade off with having either a single updatepanel encapsulating a large number of databound controls (each of which can be independently updated) or multiple updatepanels each surrounding a single databound control?

Any advice or pointers would much appreciated.

Brendy

The answer depends on what gets updated and the dependency that the controls have on each other. Typically, you want to use UpdatePanels to only update fragments of the page that need to be updated, leaving the other areas intact. This technique will also reduce the amount of data that is coming back down from the server to render the page.

So if some controls don't need to be updated regularly, then they belong within their own UpdatePanel (with the UpdateMode set to Conditional).


hi, many thanks for your reply. What I really want to know is, is there a point at which adding more updatepanels to a page starts to have a negative impact on performance? The page that I have has a 10x10 matrix with each cell containing a number of independent datadriven controls. So what's the tradeoff between having one update panel covering the entire matrix or 100 updatepanels one for each cell? Does this slow down the page load?

Cheers

Brendy

Multiple UpdatePanels in Wizard with MasterPage does not work.

I've exhausted my resources on this and still haven't found an answer. I'm trying to use the UpdatePanel with a Wizard control who's page is using a MasterPage. If I use more then one UpdatePanel at a time I get a "javascript runtime error: Object Required" Here's what I have tried:

    Using ScriptManagerProxy on the content page in addition to the ScriptManager that's in the MasterPage. Results = No effect.Stripping all javascript from both the MasterPage and The Content page. Results =No effectRemoving all comments. Results = No effect.Wrapping the entire Wizard in a UpdatePanel. Results = Not a good solution. My Wizard has 11 steps and at anytime during the steps if the user selects back on the browser it takes them completly out of the Wizard. Imagine how frustrating that would be in a Order process.Removed the page association to the Wizard. Results = Works but it's not a good solution as I lose the functionality of the MasterPage.When I use one UpdatePanel anywhere within the Wizards steps it works properly. It's only when I try to add a second Panel that I get the javascript error.Double checked my Atlas installation and files dates , sizes etc. Results = All files are correct.Searched the web for a possible solution. Results= Not a dam thing.Posted this message hereResults = TBD

I'm using VS 2005 and the March CPT release of Atlas.

hello.

this is problem related with the way the wizard control works. the problem is that the callback gets all the panels and the html only returns the visible one (so, if you have 3 panels, the wizard returns the one that is visible according with the current step, but due to the way that the callback mechanism works, you'll get all the other panels too and the client side of atlas will try to refresh those elements and this will trigger the error you're having).

to solve this, set the mode of all the updatepanels to condition. here's a demo page:

<%

@.PageLanguage="C#" %>

<!

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

<

scriptrunat="server">void P(object sender,EventArgs args)

{

if (sender == info1)

{

t1.Text = info1.Text;

}

elseif (sender == info2)

{

t2.Text = info2.Text;

}

else

t3.Text = info3.Text;

}

</

script>

<

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

<

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

</

head>

<

body><formid="form1"runat="server"><atlas:ScriptManagerrunat="server"ID="man"EnablePartialRendering="true"></atlas:ScriptManager><asp:Wizardrunat="server"ID="ma"><WizardSteps><asp:WizardStep><atlas:UpdatePanelrunat="server"ID="Pan1"Mode="Conditional"><ContentTemplate><asp:TextBoxrunat="server"ID="info1"OnTextChanged="P"AutoPostBack="true"/><br/><asp:Literalrunat="server"ID="t1"/></ContentTemplate></atlas:UpdatePanel></asp:WizardStep><asp:WizardStep><atlas:UpdatePanelrunat="server"ID="UpdatePanel1"Mode="Conditional"><ContentTemplate><asp:TextBoxrunat="server"ID="info2"OnTextChanged="P"AutoPostBack="true"/><br/><asp:Literalrunat="server"ID="t2"/></ContentTemplate></atlas:UpdatePanel></asp:WizardStep><asp:WizardStep><atlas:UpdatePanelrunat="server"ID="UpdatePanel2"Mode="Conditional"><ContentTemplate><asp:TextBoxrunat="server"ID="info3"OnTextChanged="P"AutoPostBack="true"/><br/><asp:Literalrunat="server"ID="t3"/></ContentTemplate></atlas:UpdatePanel></asp:WizardStep></WizardSteps></asp:Wizard></form><scripttype="text/javascript"src="Atlas.js"></script>

</

body>

</

html>

Hi Luis,

That worked beautifully, thank you very much! I remeber trying mode="Conditional" however I think I probably didn't set all the panels as I should have.

On a related note, I turned the step buttons into templates so I could have more freedom on placement. I'm also setting the ActiveStepIndex in the codebehind instead of using CommandName. If I wrap those buttons with the UpdatePanel they lose their ability to step, it's like they are ignoring the ActiveStepIndex or I get the JavaScript error. It would be nice to be able to include these step buttons in the UpdatePanel. On the credit card confirmation step it can take several seconds for a response and providing the progress indicator pretty much ensures the user will wait.

Is this also related to the way the wizard callback mechanisum works?


hello again.

hum...not sure on that...can you change the previous page i've posted so that it uses your templates for the step buttons? i'm a little busy now and if you'd change that page i'd be able to take 5 mins and try to understand what's going on...


Hi Luis,

I used your example and modified it to show you the behavior. I did put it in VB and pasted it below. If you will notice I have two rows of buttons. The first row are buttons inside the update panel. They set the active step in the code behind. The second set is the button templates for the wizard. Clicking the first row buttons just causes a post back. Although when you click the second row next button after clicking the first row next button the page jumps to step 3. So for some reason the index is changing but the actual step is not displaying. Also another strange behavior I observed with my existing project is when I uplaoded the new aspx files with the update panel to my isp's server, the page is actualy refreshing on updates where as it does not when I run it on my localHost. Not sure why this is occuring. I understand your busy and if you think I should repost the last issue in a new thread, I will. Just thought I would mention it here.

Thanks,

Jason

testnm.aspx:

<%

@.PageLanguage="VB"AutoEventWireup="false"CodeFile="testnm.aspx.vb"Inherits="testnm"title="Untitled Page" %>

<!

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="form2"runat="server">

<

atlas:ScriptManagerrunat="server"ID="man"EnablePartialRendering="true">

</

atlas:ScriptManager>

<

asp:Wizardrunat="server"ID="ma"ActiveStepIndex="0">

<

WizardSteps>

<

asp:WizardSteprunat="server">

<

atlas:UpdatePanelrunat="server"ID="Pan1"Mode="Conditional">

<

ContentTemplate>

<

asp:TextBoxrunat="server"ID="info1"AutoPostBack="true"/>

<

br/>

<

asp:Literalrunat="server"ID="t1"/><br/><br/><asp:ButtonID="StartNextButton1"runat="server"Text="Next"/><br/>

</

ContentTemplate>

</

atlas:UpdatePanel>

</

asp:WizardStep>

<

asp:WizardSteprunat="server">

<

atlas:UpdatePanelrunat="server"ID="UpdatePanel1"Mode="Conditional">

<

ContentTemplate>

<

asp:TextBoxrunat="server"ID="info2"AutoPostBack="true"/>

<

br/>

<

asp:Literalrunat="server"ID="t2"/><br/><br/><asp:ButtonID="StepPreviousButton1"runat="server"CausesValidation="False"Text="Previous"OnClick="StepPreviousButton1_Click"/><asp:ButtonID="StepNextButton1"runat="server"Text="Next"/><br/>

</

ContentTemplate>

</

atlas:UpdatePanel>

</

asp:WizardStep>

<

asp:WizardSteprunat="server">

<

atlas:UpdatePanelrunat="server"ID="UpdatePanel2"Mode="Conditional">

<

ContentTemplate>

<

asp:TextBoxrunat="server"ID="info3"AutoPostBack="true"OnTextChanged="info3_TextChanged"/>

<

br/>

<

asp:Literalrunat="server"ID="t3"/><br/><br/><asp:ButtonID="FinishPreviousButton1"runat="server"CausesValidation="False"Text="Previous"OnClick="FinishPreviousButton1_Click"/><asp:ButtonID="FinishButton1"runat="server"CommandName="MoveComplete"Text="Finish"/><br/>

</

ContentTemplate>

</

atlas:UpdatePanel>

</

asp:WizardStep>

</

WizardSteps><StartNavigationTemplate><asp:ButtonID="StartNextButton"runat="server"CommandName="MoveNext"Text="Next"/></StartNavigationTemplate><StepNavigationTemplate><asp:ButtonID="StepPreviousButton"runat="server"CausesValidation="False"CommandName="MovePrevious"Text="Previous"/><asp:ButtonID="StepNextButton"runat="server"CommandName="MoveNext"Text="Next"/></StepNavigationTemplate><FinishNavigationTemplate><asp:ButtonID="FinishPreviousButton"runat="server"CausesValidation="False"CommandName="MovePrevious"Text="Previous"/><asp:ButtonID="FinishButton"runat="server"CommandName="MoveComplete"Text="Finish"/></FinishNavigationTemplate><NavigationStyleHorizontalAlign="Left"/>

</

asp:Wizard>

</

form>

<

scripttype="text/javascript"src="scriptlibrary\atlas\debug\Atlas.js"></script>

</

body>

</

html>

testnm.asxp.vb:

Partial

Class testnmInherits System.Web.UI.PageProtectedSub info1_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles info1.TextChanged

t1.Text = info1.Text

EndSubProtectedSub info2_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles info2.TextChanged

t2.Text = info2.Text

EndSubProtectedSub info3_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles info3.TextChanged

t3.Text = info3.Text

EndSubProtectedSub StartNextButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles StartNextButton1.Click

ma.ActiveStepIndex = 1

EndSubProtectedSub StepNextButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles StepNextButton1.Click

ma.ActiveStepIndex = 2

EndSubProtectedSub StepPreviousButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles StepPreviousButton1.Click

ma.ActiveStepIndex = 0

EndSubProtectedSub FinishPreviousButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles FinishPreviousButton1.Click

ma.ActiveStepIndex = 1

EndSub

End

Class

hello.

though i just galnce at it, i'd say that this is the expected behavior. when a control placed inside the updatepanel generates a postback, the content of that panel is sent back to the client. so, the problem is that you're changing the updatepanel, but the scriptmanager is getting the content of the panel that caused the postback. i haven't seen if there's a workaround for this issue...


Hey Luis,

Its curious that it works if you wrap the entire wizard in the UpdatePanel. If I knew then what I know now, I wouldn't have used the Wizard.

Thanks for the help.

Jason

Multiple UpdatePanels in my web app

Hi,

In my asp.net 2.0 web app running under IE 6.0, myprimary UpdatePanel is working well in conjuction with the Timercontrol.

The problem I encounter is when I open a newaspx page in a new window (launched via javascript window.open() ). Thenew aspx page that opens in this window also has its own UpdatePanel(with a different ID of course) and a Timer control.

Notonly is my new window NOT updating via the UpdatePanel, but when Iclose this window and return control to the main window, my main windowcompletely hangs up. My browers goes white, the normal URL appears inthe address bar, but the site appears to be trying to refreshindefinitely. It appears to be an infinite refresh loop.

BasicallyI have an Orders.aspx page which displays customer orders (within aRepeater control). I have the timer set at 30 seconds and theUpdatePanel works fine. Now if a customer clicks on the "Submit Orders"link, I launch the SubmitOrders.aspx page in a new window (viajavascript window.open). SubmitOrders also contains an UpdatePanel andTimer control, which does NOT work.

I shall post the code to show you.

Thank you,

Bob

By the way, all my pages are linked to a master page. Here's what my SubmitOrders.aspx page looks like :

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

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:ScriptManager runat="server"></asp:ScriptManager
<asp:Timer ID="TimerSubmit" Interval="3000" runat="server"></asp:Timer>
...

<asp:UpdatePanel ID="UpdatePanelSubmit" UpdateMode="Always" runat="server">
<ContentTemplate>

<asp:GridView ID="GridView1" ... >

<Columns>...

</Columns>...

</asp:GridView
</ContentTemplate>

<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerSubmit" />
</Triggers
</asp:UpdatePanel>

...


</asp:Content>

<> This is the page that does not appear to be update. Then when I close it, my main Orders.aspx page hangs up.

<>Thank you for your advice and/or suggestions.

<>Bob

<>------


Bob,

It looks like you set your timer to 3 milliseconds instead 30 seconds.

30 seconds = 30,000, please verify


I set it to 3 seconds (3000 ms).

Thanks for checking...

Bob


Bob,

I too have seen a similar behavior in my web app. I have a "inbox" of records that is refreshed via a timer every 2 minutes. Users can create a new record via a new form opened as yours is (window.open) and once they click the save button the record will be asynchronously saved (form fields are within update panel) and a status message (success/failure) is displayed (via ModalPopupExtender) to indicate the result. Once the user clicks the "OK" button on the status modal it calls a javascript function (OnOkScript property) that triggers a remote refresh of the Inbox web form. Once the new record form is closed the Inbox page is usually "broken" (sometimes it happens on 1st new record, sometimes after 2nd/3rd update but it eventually happens) - all actions that trigger an async postback time out (e.g. grid sort, grid select, trying to add a new record (new window just hangs and is blank)). It seems to me that there is something that is killing the session or connection but there are no errors being generated that would give me an indication as to what is causing the problem. My thread that discusses my problem can be found here:

http://forums.asp.net/thread/1688076.aspx

Michael Jensen


Hi Michael,

Yes, I also noticed that the browserfreeze-up doesn't occur the first time. It usually happens the secondor third time I close the second window.

<> In my case, Ithink I figure out one of the potentially several reasons. I have ajavascript function that refreshes the main page when I close thesecond page. However, I think my old refresh technique is obsolete dueto the fact I'm now using Timers and UpdatePanels. Here's what I mean :

On my SubmitOrders aspx page (launched in a new window), the user can click on theReturn button and go back to the main orders page using this button :

<><asp:Button ID="btnClose" OnClientClick="javascript:OnAbort();" Width="" Text="Return" />

The OnAbort function looks like this :

function OnAbort(pActionFrom) {

// initialize client and user vars here ...

opener.location.href = 'orders.aspx?client=' + escape(lcClient) + '&user_id=' + escape(lcUser_Id) + '&action=UnlockAll';
self.close();
return;
}

I think there's a clash between thisopener.location.href command and the ajax UpdatePanel. In other words,if my refresh occurs at the same time as the Ajax-style update then mybrower freezes (my timer is set to 3 seconds on the main orders page).

Anyhow, I think I still have other issue but so far this is what I discovered...

Bob


Hi Michael,

Yes, I also noticed that the browserfreeze-up doesn't occur the first time. It usually happens the secondor third time I close the second window.

<> In my case, Ithink I figure out one of the potentially several reasons. I have ajavascript function that refreshes the main page when I close thesecond page. However, I think my old refresh technique is obsolete dueto the fact I'm now using Timers and UpdatePanels. Here's what I mean :

On my SubmitOrders aspx page (launched in a new window), the user can click on theReturn button and go back to the main orders page using this button :

<><asp:Button ID="btnClose" OnClientClick="javascript:OnAbort();" Width="" Text="Return" />

The OnAbort function looks like this :

function OnAbort(pActionFrom) {

// initialize client and user vars here ...

opener.location.href = 'orders.aspx?client=' + escape(lcClient) + '&user_id=' + escape(lcUser_Id) + '&action=UnlockAll';
self.close();
return;
}

I think there's a clash between thisopener.location.href command and the ajax UpdatePanel. In other words,if my refresh occurs at the same time as the Ajax-style update then mybrower freezes (my timer is set to 3 seconds on the main orders page).

Anyhow, I think I still have other issue but so far this is what I discovered...

Bob


Bob,

This is my implementation of performing a parent form refresh - this script is called when users click the OK button on the child form modal status popup (e.g. "The record was saved successfully.") (ModalPopupExtender property --> OnOkScript="RefreshParent(false)"):

// Function Name: RefreshParent
// Function Purpose: Trigger a async refresh of the parent form.
// Author: Michael Jensen
function RefreshParent(autoClose){

// put function within try-catch-finally block
try
{
// debug statement - set debug = true to view
if (debug) alert(">>Entered JavaScript:RefreshParent");

// define local variables
var control = GetParentDocumentElement('HiddenRefreshButton');

if(control != null)
{
control.click();
}
// if autoClose = true
if(autoClose)
{
self.close();
}
// return false
return false;
}
catch(ex)
{
var msg = "JavaScript:RefreshParent failed. ";
alert(msg + ex.messsage);
}
finally
{
// debug statement = set debug = true to view
if (debug) alert("<<Exiting JavaScript:RefreshParent");
}
}

My parent form has a hidden (style="display: none;") asp:button that is set as an AsyncPostBack trigger for the update panel so when the click event is triggered via the JavaScript it refreshes the "inbox" (gridview). It works great and I love the new functionality it brings to the table but it consistently breaks after the first/second refresh as we both have noticed. I too thought that it was causing a conflict with the timer so I tried setting the refresh behavior to use "window.opener.document.forms[0].submit()" (hard postback) but this did not resolve the issue with the parent form breaking. The autoClose is used by some child forms of the new record form that facilitate adding sub-child records so that the sub-child forms auto close after triggering a refresh of the parent record form.

Regards,

Michael Jensen


Bob,

I forgot to mention also that I have been unable to reproduce this problem when using Firefox/Netscape. I am using IE6 on my dev system but my app testers have seen the problem in IE7 as well.

Regards


I like the scripting technique you're using. Let me ask this: if youdisable the Timer control, does the parent window still break ? If itdoesn't break then I believe our conflict theory is correct.

Ifdisabling the timer doesn't make a difference, can I suggest doing whatI tried. I set my timer to 3 seconds (3000 ms) and just close the childwindow without any refreshes whatsoever. At this point just let thetimer take care of the refresh on its own. Please tell me if that works.

Theproblem I just discovered is more of a application-design issue. I usedto do a "hard" refresh as you mentioned with this script (upon closingthe child window):

opener.location.href = 'orders.aspx?client=' + escape(lcClient) + '&user_id=' + escape(lcUser_Id) + '&action=UnlockAll';

Ifyou'll notice, however, I was also using my custom "action" parameter.This notified the Orders.aspx page that I needed to unlock that user'srecords. I guess I just lost that functionality by letting the timertake control of the refresh. Perhaps I'll use a session varinstead...gotta think about it...

Regards,

Bob


would you mind showing me the code for the hidden refresh button on your aspx page ?

Thanks,

Bob


Bob,

Here is the code for the hidden Asp:Button:

<div style="display: none;"> <asp:Button ID="HiddenRefreshButton" runat="server" OnClick="HiddenRefreshButton_OnClick" /></div>

I also tried the two tests you mentioned previously. I blocked the child form from triggering a refresh both with the timer enabled and disabled and the parent form still broke. A child initiated refresh with the timer disabled also broke the parent form. I am also getting some sporadic parsing errors that I was not getting before. Back to the drawing board I guess. Will keep you posted.


I ended up successfully using your idea toaccess the hidden button from the child window using this js code (opener.document was previously the missing key in my js code).

Keep in mind that I usemaster pages, so the rendered HTML page declares my hidden refresh button asID="ctl00_ContentPlaceHolder1_hidRefreshImg" (as opposed to the simpler ID="hidRefreshImg").

function OnAbortSubmit() { // This fires when I close the child window

var hidRefresh =opener.document.getElementById("ctl00_ContentPlaceHolder1_hidRefreshImg");// hard coding the id work fine...
hidRefresh.click();

self.close();
return;

}


I put this on my main Orders.aspx pagewithin my UpdatePanel:

<> <div style="display:none">
<asp:Button ID="hidRefreshImg" runat="server" />
</div>

I do use a technique for dynamically injectingjavascript vars at runtime in order to store the actual aspx-generatedID for my controls, but the variable does not work for me in thisscenario. I'll share the technique if your interested.

Thanks again,

Bob


Bob,

Eureka!!! I figured out the problem. I have JavaScript methods that are called by my child forms when a user is clicking the "Close/Cancel" button that verify there are no unsaved changes before closing otherwise user is prompted to verify that they want to discard changes or not. If they confirmed that they wanted to close the web form I was simply calling window.close() but was not returning any value from the function which I think was a problem because the Close/Cancel button is located within the update panel (because the image changes depending on the scope of the form (e.g. new or view)) and thus despite closing the window I think somehow the AJAX event lifecycle was being initiated but terminated abnormally because of the form closing. I added a "return false;" in my finally clause for all the functions that are used in the closing of a child web form and lo and behold my parent form no longer breaks (see example function below - added statement is bolded). I hope this solution also works for you. Also, thanks for the compliment on js scripting technique - if you can get it, I highly recommend using CodeSmith Pro to develop coding templates that will help enforce standards and practices on code items (classes, methods, properties, etc.):

// Function Name: CloseVisitLog
// Function Purpose: Close the visit log form.
// Author: Michael Jensen
function CloseVisitLog(scope)
{
// put function within try-catch-finally block
try
{
// debug statement - set debug = true to view
if (debug) alert(">>Entered JavaScript:CloseVisitLog");

// declare local variables
var unsavedChanges = GetUnsavedChangesFlag();

if(scope == "new")
{
// make sure the user really wants to cancel
if (confirm("Are you sure you want to cancel creation of this visit log entry?"))
{
// close the window
window.close();
}
else
{
return false;
}
}
else if(scope == "view")
{
// if there are unsaved changes make sure the user really
// wants to close
if(unsavedChanges == "true")
{
if (confirm("There are unsaved changes, are you sure you want to close?"))
{
// close the window
window.close();
}
else
{
return false;
}
}
else
{
// close the window
window.close();
}
}
}
catch(ex)
{
var msg = "JavaScript:CloseVisitLog failed. ";
alert(msg + ex.messsage);
}
finally
{
// debug statement = set debug = true to view
if (debug) alert("<<Exiting JavaScript:CloseVisitLog");
// return false to prevent postback when window is closing
// otherwise parent form AJAX will break
return false;
}
}


Hi Michael,

I'm glad to hear you found yoursolution. I tried experiementing with the return false idea, but itstill breaks when the parent form's Timer fires off.

Here's my on abort routine again with your return false idea :

function OnAbortSubmit() { // This fires when I close the child window

var hidRefresh =opener.document.getElementById("ctl00_ContentPlaceHolder1_hidRefreshImg");
hidRefresh.click();

try{
self.close();
}
finally{
return false;
}

}

So is the "return false" statement reached even though I'm doing aself.close() before that ? In any case, I think what I'll do is justcomment out the hidRefresh.click() statement due to the fact that Ialready have a 3-second timer on the parent form. So in the worse-casethe user will wait three seconds to see the main window update. Unlessof course there was a way that I could momentarily disable the Timercontrol, then re-enable it when my main page reloads...I'll look intothat...

Thanks for the CodeSmith recommendation.

Regards,

Bob

Multiple UpdatePanels = slow (despite UpdateMode=Conditional)

Hi all,

I'd appreciate help with this as it doesn't seem to make any sense.

I have 2 UpdatePanel controls. I want them to update independently so have set the UpdateMode="Conditional". Each control has a listbox and a button, with the button click populating the listbox.

Now, if the listbox in UpdatePanel2 is empty and I click the button to fill the listbox in UpdatePanel1, this update is very quick (it just returns a handful of rows from the database).

Now, let's say I click the button to fill the listbox in UpdatePanel2, and I happen to add a large number of rows to the listbox (say a couple of thousand). This takes about 10 seconds, which is as expected.

But what I wouldn't expect is for this to dramatically slow down any subsequent updates of the listbox in UpdatePanel1. But that is exactly what happens - any update of the UpdatePanel1 listbox now takes about 10 seconds, even for a few rows. It is as if it is filling the listbox in UpdatePanel2 again.

I thought the whole point of having independent UpdatePanel controls with UpdateMode="Conditional" is to avoid issues like this. Of is there some other reason why this is happening?

Many thanks for assisting a frustrated man.

Richard

What's probably happening is that your ViewState is huge after populating the ListBox. After that, any partial (or full) postback will be transferring that entire ViewState back to the server and the server has to go through instantiating the control from that. That's going to really drag down your performance.

If you can run without ViewState on that control (or even the whole page), do so.

More information:http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/


Hi there,

Thanks for the reply.

If this was the case, I'd expect adding enableviewstate=false to both listboxes to fix the problem, but it doesn't make any difference. Just to verify, I checked the viewstate uning javascript after every async postback and it was only a few kbs throughout at most.

Anyone have any other ideas? This behaviour seems to run completely counter to the idea of independent updatepanel controls.

Cheers,

Richard


In fact, try it yourself:

Click "Update Listbox 1" first - it is instantly filled.

Don't forget the reinstantiation on the server side. Theentire Page is instantiated in every postback, not just the portion relevant to the UpdatePanel that's being refreshed. On the server side, you can basically think of a partial postback as a regular postback that takes the rendered HTML and filters it down to just what's relevant to the UpdatePanels being refreshed. However, that selectivity doesn't come into play until the entire page has finished its life cycle.

So, even though you have independent UpdatePanels, most of that independence is an illusion when thinking about performance.


Right, I see (i think). That makes me wonder: what exactly is the point of the UpdateMode=Conditional then?

It has to be said that UpdatePanels are a touch disappointing, since before ASP.NET AJAX came along we used to use XMLHTTP and javascript manually to do this and did achieve the performance benefits in such situations. I think I'll have to go back to using that.

Thanks again for taking time to explain.


UpdateMode Conditional does reduce the amount of data returned over the wire in a given partial postback. It just turns out to be a negligible gain in a situation like yours, where the bottleneck is somewhere else.

What you can do is use a web service or page methods for something like this, while saving UpdatePanels for something like a GridView where you really need the ViewState. The client side framework that we're given with ASP.NET AJAX works great for leveraging light weight services for a more traditional AJAX approach. That just seems to have been overshadowed by the ease of use of the UpdatePanel.

Monday, March 26, 2012

MultiView containing an UpdatePanel: cant switch ActiveViewIndex?

I have a button control inside of an UpdatePanel. This UpdatePanel sits inside of a MultiView control (which is NOT inside another UpdatePanel, just a regular multiview). The function that is fired from the button click is supposed to change the ActiveViewIndex, but it does not. It fires off other actions inside the function, but does not change the multiview.


Is there something I need to do to get this to work? Here is roughly what I'm talking about. In this case it's set to ActiveViewIndex = 0. I need the button to change it to index 1. Thanks!!

<asp:MultiView runat="server" ID="someID">

<asp:View runat="server"

<asp:UpdatePanel runat="server">

<contenttemplate>

<asp:Button runat="server" onclick="MyFunction" Text="CLICK ME" />

</contenttemplate>

<asp:UpdatePanel>

</asp:View>

<asp:View runat="server">

SOME LITERAL HTML CONTENT

</asp:View>
</asp:MultiView


hi rpeters,

what are you using for your MyFunction?

should be something like this, right?

multiviewAppSec.SetActiveView((

View)this.multiviewAppSec.FindControl("ViewName")));

I was simply using...

myMultiView.ActiveViewIndex = 1;



pixelsyndicate:

hi rpeters,

what are you using for your MyFunction?

should be something like this, right?

multiviewAppSec.SetActiveView((View)this.multiviewAppSec.FindControl("ViewName")));

Tried using the approach as well. No difference... :(

Anyone??


I am pretty sure I tried that before, and didn't get it to work. the definition of that property says its Sets or Gets... so it should work. Try using the

SetActiveView(view) method to make that change. You will have to pass it a reference to the View you want however. Using the findcontrol() method example I used should help you to do that. Respond back on whether it worked or not. ;)


pixelsyndicate:

I am pretty sure I tried that before, and didn't get it to work. the definition of that property says its Sets or Gets... so it should work. Try using the

SetActiveView(view) method to make that change. You will have to pass it a reference to the View you want however. Using the findcontrol() method example I used should help you to do that. Respond back on whether it worked or not. ;)

Tried it...no luck. Same result as by setting the property.


Anyone else? There has to be a way!

you stated you were using 1 as the view index to display. isn't the view you want to show actually the first view? that would mean you need to display view index ZERO (0). indexes are zero-based, meaning its it this order...

0
1
2
3
4
5
6
...


pixelsyndicate:

you stated you were using 1 as the view index to display. isn't the view you want to show actually the first view? that would mean you need to display view index ZERO (0). indexes are zero-based, meaning its it this order...

0
1
2
3
4
5
6
...

I know that they are zero-based indices. I also am using the correct view index for my application. The problem is that it seems that because it is being called from a routine that is inside of an update panel, it is trying to make the change inside that panel, rather than changing the entire page to reflect the new panel.

anyone else?? thanks.

Multiview inside updatepanel, updatepanel inside View?

Has anyone gotten this to work? I have a multiview inside an updatepanel, and I can switch tabs without a screen repaint. But then, in one of the views I tried to put an updatepanel to update something in that view and it started freaking out. (probably for similar reasons to the freakout when I tried to put an updatepanel inside the itemtemplate of a repeater)

For example, I want a view to enter billing information, but then I want to dynamically hide the states dropdown if you pick a country other than US, CA or AU. At first it told me that my trigger had to reference a valid control, so I set it to the name of my country dropdownlist. It accepted that but then it gave me an object expected javascript error. Quite frankly, my brain is about to explode from trying to wrap it around this stuff.

So, I'm going to skip the idea of hiding the state DDL and just have a default option "select if appropriate" and move on with my life. But consider this an FYI to you boys (and girls) on the atlas development team.

hello.

can you give more details about your scenario? it looks like you ended with an updatepanel inside another updatepanel...


An updatepanel inside a view inside a multiview inside another updatepanel. So yes, basically, an updatepanel inside an updatepanel. From what I understand you can nest updatepanels no? Or does that only work when you don't have something in the way like my view/multiview

hello again,

to be honest, i haven't tried...well, what i really don't understand is why you're dont' simply update the whole view...btw, can you build a small sample that reproduces that behavior and post it here? it'll have to be a simple page so that we can copy/paste it...


I built a simple page where the view has a button that changes a label, and that worked fine, but my dropdown does not: I want the states DDL to disappear when I select france. Keep in mind that I'm building a submission form and I don't want to lose input in any of the views (same as if I was using the wizard control but without all the overhead)

<%@. Page Language="VB" AutoEventWireup="false" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"
Sub Button1_Click(s as Object, e as EventArgs)
MultiView1.SetActiveView(stepone)
End Sub

Sub Button2_Click(s as Object, e as EventArgs)
MultiView1.SetActiveView(StepTwo)
End Sub
Sub checkcountriesddl(ByVal s As Object, ByVal e As EventArgs)
If countriesddl.SelectedItem.Value = "CA" Or countriesddl.SelectedItem.Value = "US" Then
statesddl.Visible = True
Else
statesddl.Visible = False
End If

End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering=true />
<table><tr><td>
<asp:button ID="button1" runat=server Text="Step 1 Tab" onclick=Button1_click />
</td><td>
<asp:button ID="button2" runat=server Text="Step 2 Tab" onclick=Button2_click />
</td></tr></table>
<atlas:UpdatePanel runat=server ID=mvup>
<Triggers>
<atlas:ControlEventTrigger ControlID=button1 EventName="Click" />
<atlas:ControlEventTrigger ControlID=button2 EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:MultiView id="MultiView1" runat="server" ActiveViewIndex=0>

<asp:View id="stepone" runat="server" >
Hi there
</asp:View>
<asp:View ID="steptwo" runat="server">
<asp:Label ID="tobeupdated" runat=server Text="Welcome to Step Two" /><br /><br />
<asp:PlaceHolder ID="statesplaceholder" runat=server>
<asp:DropDownList ID="statesddl" runat=server>
<asp:ListItem Value="AK" Text="Alaska"></asp:ListItem>
<asp:ListItem Value="AR" Text="Arizona"></asp:ListItem>
</asp:DropDownList></asp:PlaceHolder><br /><br />
<asp:dropdownlist OnSelectedIndexChanged="checkcountriesddl" runat="server" id="countriesddl">
<asp:ListItem Value="US" Text="United States"></asp:ListItem>
<asp:ListItem Value="CA" Text="Canada"></asp:ListItem>
<asp:ListItem Value="FR" Text="France"></asp:ListItem>
</asp:dropdownlist>

</asp:View></asp:MultiView>
</ContentTemplate></atlas:UpdatePanel>

</form>
</body>
</html
I tried setting autopostback=true on the dropdownlist. No effect.

I tried adding a trigger to the multiview triggers:

<atlas:ControlEventTrigger ControlID=countriesddl EventName="SelectedIndexChanged" />

So then I tried another update panel (replacing the purple section above)

<atlas:updatepanel ID="statesup" runat=server>
<Triggers>
<atlas:ControlEventTrigger ControlID="countriesddl" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:PlaceHolder ID="statesplaceholder" runat=server>
<asp:DropDownList ID="statesddl" runat=server>
<asp:ListItem Value="AK" Text="Alaska"></asp:ListItem>
<asp:ListItem Value="AR" Text="Arizona"></asp:ListItem>
</asp:DropDownList></asp:PlaceHolder>
</ContentTemplate></atlas:updatepanel>
<br /><br />
<asp:dropdownlist AutoPostBack=true OnSelectedIndexChanged="checkcountriesddl" runat="server" id="countriesddl">
<asp:ListItem Value="US" Text="United States"></asp:ListItem>
<asp:ListItem Value="CA" Text="Canada"></asp:ListItem>
<asp:ListItem Value="FR" Text="France"></asp:ListItem>
</asp:dropdownlist>

Interesting that it doesn't work, but then if you click one of the buttons that controls the multiview, that it then fires the SelectedIndexChanged

Actually, I meant to hide the placeholder, not the DDL, but what I did is pretty much the same. sorry for the confusion
Hi !
I'm having the same problem while trying to have an atlas-updatable GridView inside an atlas-changeable Multiview. Basically it's the same thing : inclusion of updatepanels... no problem with the multiview alone, no problem if my gridview is outside, but when I put one in the other my gridview can't be updated. If I suppress the grid's updatepanel, any click on it sends me back to the main view of the multiview...

I'm not sure you managed to solve yours, did you ?

Multiview inside updatepanel, Firefox error on refresh

Hi, I got this piece of code:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="true"%><%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!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>Untitled Page</title></head><body> <form id="form1" runat="server">  <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>     <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex=0> <asp:View ID="View1" runat="server"> aaa<asp:Button ID="Button1" CommandName="NextView" runat="server" Text="Next" /></asp:View> <asp:View ID="View2" runat="server"> bbb<asp:Button ID="Button2" CommandName="PrevView" runat="server" Text="Prev" /> bbb<asp:Button ID="Button4" CommandName="NextView" runat="server" Text="Next" /></asp:View> <asp:View ID="View3" runat="server"> ccc<asp:Button ID="Button3" CommandName="PrevView" runat="server" Text="Prev" /></asp:View> </asp:MultiView> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

So basically it's just a multiview inside an updatepanel. It works when used properly, but in FireFox (not in IE and Opera), I get a little error. Say on the first view, I press next. Then I refresh the browser. Unlike when there's no update panel, the view resets to the first view. [This is not the MAIN problem, but help here would also be welcome].

Now, after the refresh if I press next, I get this error in FireFox(again, not in IE or Opera):

The state information is invalid for this page and might be corrupted.

Could someone give me a fix for this problem? I'd also like to know if it's possibe to retain the view on refresh instead of it resetting to the first one.

Thanks.

I copied your multiview and ran it, it works fine for me under FireFox 2.0.0.1

The only different is that my scriptmanager containsEnablePartialRendering="true"

Try it again or create a new Ajax WebSite for testing ... Good Luck.


Hi,

Thanks for the reply. However, I just can't get it to work. I created new ajax enabled sites (both on file system and IIS, thinking maybe it's an IIS setting), didn't help. I'm running 2.0.0.1 of FF - the same as you.

Could you try

www.funkybears.com/test.aspx

On the first page, hit next. Then use the refresh button of firefox. Click next after the page loads. I'm getting the error right then.

Also, if I don't use an update panel, if I hit refresh, the currently selected view shows up. With the updatepanel, it always returns to the first view. Is there a way to counter this?

Thanks.


Bump :)
I tried your URL, it works fine under both browser IE7 and FF.

MultiView inside UpdatePanel - Validators not working

Hi All,

I have a problem with a page I'm building at the moment. Basically it includes a multiview with a number of views, in which where there is a usercontrol that contains a number of text fields with custom validators.

Without an updatepanel around the multiview, all works fine. However, when I put an updatepanel around the multiview to prevent full page rendering on postback, the valdidators fail. I have included a very simplified example below to explain my point.

My ASPX Page:

1<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>23<%@dotnet.itags.org. Register src="http://pics.10026.com/?src=WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>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" EnablePartialRendering="true" />12 <br />13 <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" UpdateMode="Always">14 <ContentTemplate>15 <asp:Button ID="Button1" runat="server" Text="View 1" OnClick="Button1_Click" CausesValidation="false" />16 <asp:Button ID="Button2" runat="server" Text="View 2" OnClick="Button2_Click" CausesValidation="false" />17 <asp:Button ID="Button3" runat="server" Text="View 3" OnClick="Button3_Click" CausesValidation="false" />18 <br />19 <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">20 <asp:View ID="View1" runat="server">21 <asp:Label ID="Label1" runat="server" Text="View 1"></asp:Label>22 <uc1:WebUserControl ID="WebUserControl1" runat="server" />23 </asp:View>24 <asp:View ID="View2" runat="server">25 <asp:Label ID="Label2" runat="server" Text="View 2"></asp:Label>26 <uc1:WebUserControl ID="WebUserControl2" runat="server" />27 </asp:View>28 <asp:View ID="View3" runat="server">29 <asp:Label ID="Label3" runat="server" Text="View 3"></asp:Label>30 <uc1:WebUserControl ID="WebUserControl3" runat="server" />31 </asp:View>32 </asp:MultiView>33 </ContentTemplate>34 </asp:UpdatePanel>35 </form>36</body>37</html>38
Code Behind:
1public partialclass _Default : System.Web.UI.Page {2protected void Page_Load(object sender, EventArgs e) {3 }4protected void Button1_Click(object sender, EventArgs e) {5this.MultiView1.ActiveViewIndex = 0;6 }7protected void Button2_Click(object sender, EventArgs e) {8this.MultiView1.ActiveViewIndex = 1;9 }10protected void Button3_Click(object sender, EventArgs e) {11this.MultiView1.ActiveViewIndex = 2;12 }13}
 The User Control:
 
1<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs"2 Inherits="WebUserControl" %>34<script type="text/javascript">5 function v(sender, args) {6 var v1 = $get("<%=TextBox1.ClientID%>");7 alert(v1);8 }9</script>1011<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>12<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="true" />13<asp:CustomValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"14 Font-Bold="True" Font-Size="X-Large" Text="*" ClientValidationFunction="v" ValidateEmptyText="true" />15

Create the project and add the user control and the default.aspx page. Run it. Try the validator in the View1 (selected by default), it works fine, alerting an [object] to denote the field was found ok.

Switch to another view and all you get alerted is [null] showing the control was not found.

Can anyone get this code to work with the updatepanel?

Andy.

Hi;

Hi;

I had this problem with Ajax Asp.NET Beta 2;
So.. this is a bug, and it was fixed on Features November CTP

http://go.microsoft.com/fwlink/?LinkID=77294

You need download, install and configure the the web.config;
Join it;

[]'s

I was sure I was using the Nov issue. I will check...

Andy.

multiview requiredfieldvalidator and updatepanel error - entire simple code posted

Problem is when I click on linkbutton2 then click on the button on that page is get the null error. It's being caused because it's looking for the validator from view1.

I know I can say causesvalidation=false, but I will have tons of items in view2 and don't want to do it that way.

I want to say RequiredFieldValidator1.enabled=false for the view2 section. But where do I call this? Also when they go back to view1 it should say this RequiredFieldValidator1.enabled=true.

code behind:

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MultiView1.ActiveViewIndex = 0
End Sub

Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MultiView1.ActiveViewIndex = 1
End Sub

source:

<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<atlas:UpdatePanel runat="server" ID="calendarupdatepanel">

<ContentTemplate>

<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CausesValidation="false">Search</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click" CausesValidation="false">Results</asp:LinkButton>
<br />
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="view1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
</asp:View>
<asp:View ID="view2" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:View>
</asp:MultiView>
<asp:Label id="ActiveViewLabel"
BorderStyle=None
Font-Size=Small
BackColor="#ffff66"
runat="Server" Text="" >
</asp:Label>
</ContentTemplate>
</atlas:UpdatePanel>

</form

fixed this one - never mind

multiview refresh inside updatepanel

i've a gridview based on the dropdownlist and multiview with two views based on the gridview selection.

when i change selection in my dropdownlist without click on my gridview, the information in the multiview in view1 and view2 is refreshed, but once i change the selection in my gridview the refresh happend only in the active view not in the other.

help me please

S.O.S ...Sos...sos...helpConfused


thanks to all for your reply!!!Wink.

i've found the solution it's working but i'm sure there is an other way and better.

when i change the selection in the gridview i refresh the sql connection.

and when i set the view1 or view2 to active i refresh the connection too.

gridveiw1.datasourceid="sqlconnectin1".

MultiView within UpdatePanel causes PostBack... =(

The subject says it all. Due to a video playing, when new content is requested I need the page to NOT post back so the video doesn't restart. However, the page is still seeing a postback. Any ideas are welcome.

[removed by author]

Hi,

Is the video in the updatepanel?

Multiview, updatepanel, animation extender....bad combo?

I got a multiview inside of an updatepanel. The multiview has a view which has an updatepanel. There's an animation extender on the inner updatepanel. The extender has an animation of fadeout on onloading and fadein on onloaded.

When I run it, when the inner updatepanel is to update, I see it fadeout ever so slightly in IE and not at all in firefox. The updated data doesn't fade in, it just shows up. I set the duration of the fadeout/in to high values to test. didn't help. The change just shows without animation.

Is there a way to do this?

Did some more fiddling. It seems putting an updatepanel inside an update panel removes the animation.

Just had to remove the children as triggers and always update and it works.

Multiview, modalPopup, updatepanel, popupcontrolextender

Hello,

I have a multiview that contains six views. Two of the views have update panels on them. I had it working with a popupcontrolextender (for a calender) and using updatepanel to move between the views without postback.

However, I added modalPopup to one of my views and now it doesn't switch between the views anymore. If I take the modalPopup out, it works again.

Has anyone run into this before? If so, how did you get around it?

Check the JavaScript debugger window for script errors, maybe?

MutuallyExclusiveCheckBoxExtender in Panel in Updatepanel in Repaeter!

Hi,

I've used this site for reference many times (coz i'm that good!) but this is my first post, so thanks for all the help guys!

Anyway...

I have a page with a repeater control. inside the repeater, i have an updatepanel (i don't need the whole repeater refreshed), and inside that, i have 2 checkboxes that i want to be mutually exclusive!

straightforward huh? er...no!!

adding the MutuallyExclusiveCheckBoxExtender to the panel at Design time causes ALL the checkboxes to uncheck when you click on one, and i can't seem to add the MECE's dynamically at runtime - when i click, nothing happens.

Here's some code for you... it's placed inside Repeater_ItemDatabound

//Check the boxes depending upon user's role Panel myPanel = e.Item.FindControl("RolePanel")as Panel;if (myPanel !=null) { CheckBox myCbA = myPanel.FindControl("cbAdmin")as CheckBox;if (myCbA !=null) { myCbA.Checked = Roles.IsUserInRole(myUser,"Administrator"); } CheckBox myCbB = myPanel.FindControl("cbUser")as CheckBox;if (myCbB !=null) { myCbB.Checked = Roles.IsUserInRole(myUser,"User"); }//Add some ajax! AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender MeCeA =new AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender(); AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender MeCeB =new AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender(); MeCeA.ID ="MeCeA" + ItemCount.ToString(); MeCeA.Key ="Roles" + ItemCount.ToString(); MeCeA.TargetControlID = myCbA.ID; MeCeB.ID ="MeCeB" + ItemCount.ToString(); MeCeB.Key ="Roles" + ItemCount.ToString(); MeCeB.TargetControlID = myCbB.ID; myPanel.Controls.Add(MeCeA); myPanel.Controls.Add(MeCeB); }

and the source... placed inside the RepeaterItem ItemTemplate

<ajax:UpdatePanel ID="UserDetailsUpdatePanel" runat="server" UpdateMode="Always"> <ContentTemplate> <cc1:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="lblResponse"> <Animations> <OnLoad> <FadeOut Duration=".5" Fps="20" /> </OnLoad> </Animations> </cc1:AnimationExtender> <div class="RolePanel"> <asp:Panel ID="RolePanel" runat="server"> <asp:CheckBox ID="cbAdmin" runat="server" Text="Administrator" AutoPostBack="true" /><br /> <asp:CheckBox ID="cbUser" runat="server" Text="User" AutoPostBack="true" /><br /> <center><asp:LinkButton ID="lbtnRoles" runat="server" Text="Submit" /></center> <center><asp:Label ID="lblResponse" runat="server" Visible="False" /></center> </asp:Panel> </div> </ContentTemplate> </ajax:UpdatePanel>

I hope someone can help me - this ajax stuff makes my sites look and feel all funky!

TIA

Ché

Seriously... is there no-one who can help me?

Hi,

If I understand the question correctly, you want all 2 to be mutually exclusive checkboxes.

Have you tried adding 2 MutuallyExclusiveCheckBoxExtender in design mode and specifying the same key for both of them?


Yep, i tried that, but where it's inside a repeater it clears all the checkboxes including ones in the different repeateritems.

so, i had the brilliant idea of dynamically creating the extenders at runtime and giving each pair a key, also created at runtime so it's different for each repeateritem.

didn't work.*sob*

so then i thought of grabbing each extender as the repeateritem was databound and applying the unique key there...

nope - didn't work!

Take a quick look at this...


once, i thought it'd be simple!!

TIA for any help!!

Ché


Sorted It!!

one of my plans was indeed correct - i didn't set a key in design time, then at runtime, i grabbed the two extenders and set a unique key for them on each RepeaterItem_DataBound.

Job done!!


Saturday, March 24, 2012

My UpdatePanel does not work

Hi,

I am trying to use Updatepanel, but it does not work. The whole page is refresh it. What am doing wrong??

That is the code : (am using a master page)

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder2"Runat="Server">

<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true">

</asp:ScriptManager>

<tablestyle="width: 600px;"id="TABLE1"align="center">

...............................................................

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<cc1:MaskedEditExtenderID="MaskedEditExtender1"TargetControlID="tbCuentaBancaria"Mask="9{4}-9{4}-9{2}-9{10}"runat="server">

</cc1:MaskedEditExtender>

<tr><tdcolspan="4">

<asp:CheckBoxID="cbCuentaBancaria"runat="server"Text="No tengo cuenta bancaria"OnCheckedChanged="cbCuentaBancaria_CheckedChanged"AutoPostBack="True"/></td></tr>

<trstyle="height: 35px;">

<tdstyle="width: 176px"><asp:LabelID="Label4"runat="server"Text="Entidad Bancaria*"Width="110px"></asp:Label></td>

<tdstyle="width: 393px"><asp:TextBoxID="tbNombreBanco"runat="server"></asp:TextBox></td>

<td><asp:LabelID="Label5"runat="server"Text="Cuenta Bancaria*"></asp:Label></td>

<td><asp:TextBoxID="tbCuentaBancaria"runat="server"></asp:TextBox></td>

</tr>

</ContentTemplate>

</asp:UpdatePanel>

..............................

</asp:Content>

To useUpdatePanel controls with master pages, you can put aScriptManager control on the master page. In this scenario, the master page provides aScriptManager control for every content page.

Check UpdateMode property of UpdatePanel, whether it is set to "Conditional" or not ?

See for more details...

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


Thanks,

I moved the ScripManager to the Master Page but nothing happen. I have modified a little the code inside the UpdatePanel and now is working. i think it was a problems with the tr and td structure.