Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

ATLAS UpdatePanel Experiments


:P
On this page:

 

So I'm finally getting around to spending a little more time with ATLAS. Today I'm looking at UpdatePanels which in concept are pretty damn cool, because they can make really short work of updating content on a page even if the page was designed with no AJAX concepts in mind.

 

An ATLAS UpdatePanel works by wrapping a section of your page with an UpdatePanel object. The panel acts as a container and marker that ASP.NET uses to decide what needs to be updated on a Page level callback. To do this you:

 

  • Create your form without any thought to AJAX <g>
  • Add an UpdatePanel around the section you want updated
  • Add an Event Trigger to the UpdatePanel to have a source action
  • Add a ScriptManager object to the page and set EnablePartialUpdates=true

And realistically that's it for simple things.

 

My sample that I've been using for simple AJAX tests is a listbox of Northwind customers, which on selection updates a customer record displayed in Textboxes.

 

Add the script manager:

 

<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">

</atlas:ScriptManager>

 

 Wrap the Customer display area into an UpdatePanel:

 

<td valign="top"

    style="padding-left: 20px; padding-top: 10px; padding-right: 10px;height: 435px;">

<atlas:UpdatePanel ID="CustomerUpdatePanel" runat="server">

<Triggers>

    <atlas:ControlValueTrigger ControlID="lstCustomers" PropertyName="selectedIndex" />

</Triggers> 

<ContentTemplate>

 

<asp:Label ID="Label1" runat="server" Text="Name:"></asp:Label><br />

<asp:TextBox ID="txtContactName" runat="server" Width="350px" Text="<%# this.Customer.Entity.Contactname %>"></asp:TextBox><br />

 

…etc…                       

 

    </ContentTemplate>                                              

</atlas:UpdatePanel>                              

</td>

 

Notice the trigger which ties the update to the SelectedIndex property. Note this is the SERVER SIDE property, which means that you still need AutoPostBack to true on the list.

 

But that's pretty much it. First shot: It works really well. Literally the 4 steps above and I've made a standard POSTback form able to use AJAX callbacks to bring down the updated customer data. No flicker – life is good.

 

It's a pretty slick concept – ATLAS basically goes back to the server and runs the page as it normally would, but when it comes time to render it's going to render only the UpdatePanel content plus the page header, including the all important ViewState. It then ships all of that back to the client. Nice!

 

Until you take a look at what's going over the wire!  Because the ListBox by default is living in ViewState it's going back on the Callback POST buffer. And it also comes back from there server after the callback.There's goes our 'small' server side callback request.

 

So, thought #2: Turn off viewstate on the list. I now have a smaller payload going to back to the server, but it also doesn't work. Right – I need to rebind the list on every hit. So I add my DataBind() in Page_Load() on the list every time instead of just if (!Page.IsPostBack).  But it still doesn't work because now ASP.NET can't reassign the SelectedValue properly and so my selection gets lost and the Customer data also doesn't get updated. So I have to move the databinding code into OnInit() so the list is bound prior to the PostBack data being assigned to the list. OnInit() wouldn't be my choice for databinding, normally, but it works.

 

Not quite as simple as it looks but still pretty cool because I didn't have to change much on the server and there's no client code even if I did have to understand how to deal with the list issue which IS different than a Page PostBack.

 

So far so good.

 

Ok, the next step is to also be able to update the List when a value is changed. And here my luck runs out. So I add a second UpdatePanel and wrap the List into it. I add another trigger for a Refresh button:

 

<atlas:UpdatePanel ID="ListUpdatePanel" runat="server">

<Triggers>

    <atlas:ControlEventTrigger ControlID="btnRefresh" EventName="Click" />

</Triggers> 

<ContentTemplate>

    <asp:ListBox ID="lstCustomers" runat="server" Height="442px" Width="300px"

                 OnSelectedIndexChanged="lstCustomers_SelectedIndexChanged"

                 AutoPostBack="True" EnableViewState="false" >

    </asp:ListBox>

</ContentTemplate>

</atlas:UpdatePanel>                     

 

Now there are two update panels on the form. When I run the form it actually still works, but not quite right. The problem is that both UpdatePanels are refreshing unconditionally. They're not refreshing based on which panel fired the event.

 

There's gotta be a way to check which Panel is updating and maybe then you can selectively update data on the Page. There's an IsUpdating property on the UpdatePanel control. Unfortunately it always returns false. It also looks like the wrong event id is getting sent back to the server. When I click on the list to select a customer record here's what I get over the wire:

 

ScriptManager1=ListUpdatePanel&__EVENTTARGET=lstCustomers&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwUKMTc4OTI4MjczNGRkCqAyB8haLbw3AeneYTyE7Hgahxc%3D&lstCustomers=CENTC&txtPK=&txtContactName=&txtCompany=&txtAddress=&txtCity=&txtRegion=&txtPostalCode=&txtCountry=&

 

ScriptManager1 is set to ListUpdatePanel – which is not the right panel that initiated the callback. The CustomerUpdatePanel was the one that fired the event.

 

So unless I'm missing something obvious (which is easy to do without any documentation) it looks like currently multiple UpdatePanels are just not supported. I hope this is something that will be addressed in future revs, because it seems that this mechanism would be great for enhancing existing applications without much code at all even if the code returned is bloated.


The Voices of Reason


 

Fredrik
March 02, 2006

# re: ATLAS UpdatePanel Experiments

Set Mode="Conditional" on the UpdatePanels ;)

Rick Strahl
March 02, 2006

# re: ATLAS UpdatePanel Experiments

Did that - forgot to mention that. Didn't change anything. Both panels are still updating.

Conditional - based on what condition is the question.

Fredrik
March 02, 2006

# re: ATLAS UpdatePanel Experiments

Did a quick test with two UpdatePanels and a button triggering each now, and they seemed to update conditionally. Your feedback wouldnt let me post the code though, saying my post was too long..

scottgu
March 02, 2006

# re: ATLAS UpdatePanel Experiments

When you set an updatepanel to conditional, it only renders when one of three things happen:

1) A control within it is clicked and causes the post-back (this is nice since it means the control encapsulation model just works).

2) A trigger is declaratively wired up from that update-panel to another control on the page. The trigger mechanism allows you to fire when either a control value has changed, or if a control event fires.

3) If you programmatically call the "Update()" method on the panel. This is useful when you want to have server conditional logic to indicate whether the panel should refresh (giving you total control).

Two other cool features for you to play with while the updatepanel are: progresstemplates and error handling. When you add a progress template to the page it automaticlaly shows while the ajax callback is occuring. You can embed a "updating" text message or an animated .gif in there to easily provide visual feedback for users (no need to write javascript code). The error handling stuff also makes it much easier to handle errors at runtime (which today can be a mess with a lot of ajax solutions).

Hope this helps,

Scott

scottgu
March 02, 2006

# re: ATLAS UpdatePanel Experiments

One other thing to note about the databinding code for the listbox above. If you use one of the declarative datasource controls in V2 (for example: sqldatasource or objectdatasource), and then turn off viewstate, it will automatically populate the listbox for you at the right page lifecycle event (for example: OnInit -- before the viewstate is applied back). This allows you to build your page once, and then tweak viewstate settings based on your scenario without having to change code.

scottgu
March 02, 2006

# re: ATLAS UpdatePanel Experiments

And one more last thing while I'm at it. ;-)

I think the issue you might be having above with both panels updating is what Fredrik suggested - which is to set the mode on the updatepanel to conditional. For example:

<atlas:UpdatePanel ID="ListUpdatePanel" mode="conditional" runat="server">

This will cause the updatepanel to refresh only if one of the three conditions I mentioned in my comment earlier apply.

Hope this helps,

Scott

tim
March 02, 2006

# re: ATLAS UpdatePanel Experiments

multiple update panels are supported -- look at the master/detail sample on asyncpostback.com -- it has 3 update panels fired on triggers of each other. NOTE: the sample isn't using effective use of viewstate at all (not meant to sample that), but does show multiple update panels firing appropriately

now if you want multiple update panels and multiple updateprogress' -- that's another story ;-)

Rick Strahl
March 02, 2006

# re: ATLAS UpdatePanel Experiments

Scott,

Thanks for the clarfication. Based on what you're saying I see what the problem is with Conditional:

If I select the ListBox item, it fires an AutoPostback (without that nothing happens) and since the list is the originating list box contained inside of the second update panel it also gets updated.

Now the question is how can you tell the UpdatePanel not to update at all unless you turn it on explicitly. I think a Mode="Never" is required that only updates eitehr when Update() is fired or when the Mode is changed on the server.

Maybe a better name for the property is AutoUpdateMode...

So the question remains - How would I use an update panel in this scenario to update only the Detail view area or only the list (the latter should be easy by removing the buttons that initate the update outside of the panel.

scottgu
March 02, 2006

# re: ATLAS UpdatePanel Experiments

Hi Rick,

I think based on what you are saying that the ListBox doesn't need to be in an <asp:updatepanel> at all. If it never updates except on the origional request, then there is no reason for it to be in an updatepanel. You can still set autopostback=true on it -- its postback will still go via Ajax in that case if you have a trigger in the other updatepanel pointing to it -- in which case only the DetailView update panel would be updated.

Let me know if that makes sense -- or feel free to shoot me an email with a sample and I can send it back. :-)

Thanks,

Scott

Rick Strahl's WebLog
March 07, 2006

# More ATLAS UpdatePanel weirdness

Still mucking around with the UpdatePanel which should be simple. But as it turns out the UpdatePanel mucks with the page postback cycle on callbacks that results in subtly different behavior than a true POSTBack that complicates matter significantly. On first blush it looks that in many cases the use of ViewState for many controls is a requirement to get page state back on a callback.

scottgu
March 09, 2006

# re: ATLAS UpdatePanel Experiments

No -- you don't need to have viewstate enabled to use UpdatePanel. You can turn off viewstate for any controls contained within it.

Hope this helps,

Scott

Joel Rumerman
March 28, 2006

# re: ATLAS UpdatePanel Experiments

Finally a conversation thread regarding implicit vs. explicit triggers.

If I put a control inside an UpdatePanel it automatically acts as a postback event for that UpdatePanel. This is what I call an implicit trigger. This is in contrast with those controls that are explicitly tied to an UpdatePanel through the Triggers collection and are normally placed outside the UpdatePanel. The question remains; will there be a way to have a control within an UpdatePanel NOT act as an implicit trigger for that UpdatePanel, but rather as a normal control that causes a full page postback? Maybe a declarative statement that tells the UpdatePanel what controls inside to ignore??

Just a thought.




Rick Strahl
March 28, 2006

# re: ATLAS UpdatePanel Experiments

Joel,

I asked for explicit behavior on the UpdatePanel and I hope this is under consideration. Scott and I were talking about a 'manual' mode that would update only if you explicitly tell it to via code.

I think the idea that Conditional posts back and unpdates if a trigger resides in the panel is not a good one. This basically requires you in most cases to try and isolate your triggering controls outside of a panel which is not always possible.

I like the way this works in Anthem much better which requires the explicit server side marking of any control you want to update. Being explicit in an AJAX environment is a good thing IMHO - you don't want to update anything that you don't need to update to preserve bandwidth. As it is the server side approaches are pretty heavy weight in terms of what they ship over the wire.

Marcio C Esteves
April 04, 2006

# re: ATLAS UpdatePanel Experiments

I put together a page that uses several UpdatePanels and triggers. They all work very well, the right panels refresh when the right properties are changed or events are fired. Fine.

However I've found some issues using the UpdatePanel as well. Like Rick said the IsUpdate property always returns false no matter what.

I have one sittuation where I call a server method to dynamically add a record to my database. That function returns a count and if the count is 0 (meaning record could not be inserted) I just display a dynamic error msg and nothing needs to be refreshed. However if the count is > 0 (and it can be even more than 1) then I want to refresh one of my UpdatePanels. I've tried to call Update() method on the server side right after I insert the records, before returning to the javascript callback function. This call triggers a postback, the Page_Load() handler is called, but again the IsUpdate is false for all panels.

Hopefully someone out there knows a workaround for this.

Mark Koesel
April 25, 2006

# re: ATLAS UpdatePanel Experiments

Joel Rumerman wrote:

"The question remains; will there be a way to have a control within an UpdatePanel NOT act as an implicit trigger for that UpdatePanel, but rather as a normal control that causes a full page postback? Maybe a declarative statement that tells the UpdatePanel what controls inside to ignore??"

I had played with this for sometime a while back, but had no luck and gave up on it.

However, today, I stumbled across one solution rather accidentally. Note, however, that this will only work for controls implementing IButtonControl, so it is not a completely general solution. What you can do is set the control's PostBackUrl (which is new to ASP.NET 2.0) to the same page that the control is already in. Atlas now thinks that this control is actually posting back to an entirely different page, so it disables partial page rendering for that control.

Eoin Campbell
May 02, 2006

# re: ATLAS UpdatePanel Experiments

Hey Guys,

Just while we're on the topic of multiple Update Panels, is there any way to change the following behaviour for the <UpdateProgress> Control.

I have 3 update panels on a webform.
Each has its own button within the panel
Each Panel is set to conditional mode
And Each UP has an UpdateProgress Control containing nothing more than a swirling animated gif.

The problem is that while the button clicks in each respective panel, only update that panel... they make the UpdateProgress section in all panels visible, for the duration of the call.

i.e.
Clicking UpdatePanel1.Button1 only causes UpdatePanel1 to re-render, but makes the following visible
UpdatePanel1.UpdateProgress1
UpdatePanel2.UpdateProgress2
UpdatePanel3.UpdateProgress3

Is this expected behaviour or something that will be changed in later CTPs ?

Thanks Guys,
EoinC

Kim Terp
May 16, 2006

# re: ATLAS UpdatePanel Experiments

I have a gridview that contains a list based on data from a database. When a user wants to make a new entry, a new window opens for him to add data. When he submit, the data is written to the database, I close the window (self.close()) and want to update the gridview on the parent page. From the child window I can call a javascript function on the parent called refrechMe(). Is it possible for me to force an update from that javascript function on the parent page on the updatepanel on the same page? Or what would you suggest me to do?

Rick Strahl
May 16, 2006

# re: ATLAS UpdatePanel Experiments

Last I checked there was no way to do this from the client but this may have changed in recent builds. The way I've done this in the past is by putting an invisible (Button.style.display='';) button inside of the panel and forcing it to be clicked which forces the update.


Nick Blake
May 17, 2006

# re: ATLAS UpdatePanel Experiments

My update panel works fine as long as I'm not messing with the <HEAD> tag on the page. However, I have a user control inside the <head> tag that links some stylesheets, hooks up some javascript files and registers client script blocks. If I leave this control in, the UpdatePanel does not update. It posts back to the server, does what it needs to do, pops the UpdateProgress, but when it's done, the content of the panel is not updated. I'm still playing with the control, taking out things one by one to see what exactly causes this, but it appears that *anything* extraeneous in the <head> prevents it from working correctly. Any ideas?

Rick Strahl
May 17, 2006

# re: ATLAS UpdatePanel Experiments

Nick, are you dynamically adding things to the header in your code? I remember I ran into something like this previously where all of the Server Controls in the update panels re-render properly but any code that updates the base page - headers, scripts, even Post Back scripts - won't change.

For example, I had a form where a datagrid with pagers is initially disabled and in an updatepanel. Then on the ATLAS update callback it gets enabled and it shows, but the Paging buttons fail because the __doPostBack function hasn't been included in the page.

I'm not sure how they are going to solve this sort of problem with these controls. The only thing I can think of is to make sure that everything gets set properly in the original page generated.

Nick Blake
May 18, 2006

# re: ATLAS UpdatePanel Experiments

Thank you Rick. Yes, technically I am writing to the header dynamically but not at the time of the UpdatePanel postback. There is a user control inside the <head> tag of the page and the Page_Load event of that control is what writes out to the header. The good news is I narrowed down the offending html to the following 3 lines. The bad news is I don't know why they cause the panel not to update. If I remove these 3 lines it works perfectly but hey, I kinda want my site to look nice ;)
<meta http-equiv="refresh" content="3600;URL=http://myclienturl/Logout.aspx?Timeout=1">
<link rel="stylesheet" type="text/css" href="../styles/main.css">
<link rel="stylesheet" type="text/css" href="../styles/print.css" media="print">

Micael Baerens
May 23, 2006

# re: ATLAS UpdatePanel Experiments

FYI, I also seem to be experiencing this stylesheet issue. In my case the error occurs when this line is in the header:

<link rel="Stylesheet" href="<%= Page.ClientScript.GetWebResourceUrl(typeof(Rating), "Firespirit.Resources.Web.UI.WebControls.Rating.Default.css" ) %>" type="text/css" />

Chandrakanth
May 30, 2006

# re: ATLAS UpdatePanel Experiments

I have two update panels, one for gridview
and the other one for details view. Since i have to refresh gridview when i update or insert an item from details view i made the enableviewstate of detailsview "false".
When i change the selected index or pageIndex of gridview i trigger the detailsview.
But details view remembers the selectedindex and pageindex of last postback and so it gives the last selected item. Am i goofing up here or is it a bug with update panels?

Chandrakanth
May 30, 2006

# re: ATLAS UpdatePanel Experiments

Hi,
I got it right. The enableviewstate on the gridview has to be false and detailsview has to be true. Updatepanels do rock!!

LCID Fire
June 06, 2006

# re: ATLAS UpdatePanel Experiments

Well I absolutely agree with Rick - explicit behaviour is absolutely needed. I don't care to have to disable it - but I need the option to do so (you should have seen my face when I recognized that a post in another, untriggered, UpdatePanel was actually causing a round trip)

Cobus
June 12, 2006

# re: ATLAS UpdatePanel Experiments

Hi,

I too agree with Rick. And this issue being my exact problem today. After spending hours implementing Atlas i am now facing the decision to totally remove Atlas or somehow come up with a solution to my problem.

I have a usercontrol that contains a datagrid, this datagrid has been placed inside an update panel along with other controls to support filtering and sorting on the grid. This works 100% fine. No flashing and very elegant. But when the user clicks on a record in the datagrid, i have to load a new user control to the page, containing relevant data for the selected record.

This does not work now as the click even on the datagrid does not cause a full postback, thus the new user control is not rendered.

What i realy want is that the click even on the datagrid causes a full page postback. (We used to have Anthem implemented on the application, and this allows one to do this!) Which is basically what is spoken about in the posts above.

Does anyone know if there is a workaround for this issue or has it been addressed..?

Rick Strahl
June 12, 2006

# re: ATLAS UpdatePanel Experiments

Cobus, you can have a regular non-server button in the panel or outside of it and trigger it's click event to submit the form. This works fine but you may need to manually capture the click. Alternately you can also put an ASP.NET server button on the form, set 'display:none' and trigger it to click.

That's the workaround I've been using - ugly but it works for now. Hopefully this will get addressed in the future.

Cobus
June 13, 2006

# re: ATLAS UpdatePanel Experiments

Hi Rick,

I managed to get it working by the way you suggested but it wasnt without other problems.

1. The button`s click event handler executed before the SelectedIndexChanged event of the datagrid and by that time i was not able to determine what the newly selected index of the datagrid was to retreive the correct datakey from my grid.

So i used the same code and assigned the id that i needed to work with to the eventarguments like this:

function fullPostback(id)
{
$object("_PageRequestManager")._doPostBack( "overviewUC$DUMMYPOSTBACK", id );
}

Then removed the SelectedIndexChanged event of the datagrid, used the button`s click event and retreived my id that i needed via Request.Form["__EVENTARGUMENT"]

Dont know if this is the correct or best way to do it... but it works!

The SelectedIndexChanged event of the grid did the job, got the correct id etc... but for some reason it would not display the newly created usercontrol in the UI. Thats why i had to do what i did above. But i do find it strange though... unless i am missing something.

Thanks for the help!


Cobus
June 13, 2006

# re: ATLAS UpdatePanel Experiments

Hi Rick,

Thanks for your advice. I did it in the way you said and it worked like a charm, But with the charm i also received another problem.

The SelectedIndexChanged event of the datagrid would fire after the click even of the button that does the full postback which is fine... but when i create the new usercontrol in the the SelectedIndexChanged event it does not appear in the UI. Only if i create it in the click event of the button it appears in the UI.

So i removed the SelectedIndexChanged event, fired the __doPostback and assigned the id that i would normally retreived via the DataKeys to the eventarguemnts and retreive it back on the buttons click even. And bob`s your uncle it works.

If it is the correct way or best way i dont know.

//Client Side
function fullPostback(id)
{
object("_PageRequestManager")._doPostBack( "overviewUC$DUMMYPOSTBACK", id );
}

//Server Side
string parameter = Request.Form["__EVENTARGUMENT"];

Thanks for the help.

Brian
June 15, 2006

# re: ATLAS UpdatePanel Experiments

I have followed your instructions very closely and I'm having problems getting this thing to work.

When I click the button that is supposed to trigger the updatepanel, nothing updates. I am positive that the codebehind is actually running, because I was given an error message (trying to run Update() without the mode being conditional). Any thoughts?

Thanks.

Hans
June 19, 2006

# re: ATLAS UpdatePanel Experiments

I'm running into a similar issue...

bad meta tags and/or stylesheet link tags cause update panels to not update... if you debug through atlas's javascript you will notice that there are some missing nodes; anyway, the reason my meta tags where bad in the first place was because I had server-side script that for some reason did not get parsed... (e.g. <link href="<%=mystylesheet%>"...) I'm still not sure why this was happening but to get around it, I added an extra <%=""%> inside the meta/link tags (I'm not sure why this fixed it or what instinct prompted me to try this, but whatever...


another issue... (forgive my gear shifting)

using code-behind

* Label in update panel "A"
* button click triggers update panel "A" - to change the label's text (works)
* add button to it's own update panel "B"
* dropdown SelectedIndexChanged triggers update panel "B" - to enable/disable the button (works)

but now the button click no longer updates panel "A".

one interesting thing I noticed (which I'm not sure if it is at all related but that I was hoping someone may shed some light on) is that after the button click postback , the browser's title bar seems to change from a user friendly title to the browser's default page url. This does not happen with the dropdown, just the button...


Hans.


Josh Gough
June 28, 2006

# 98,000 byes on the POSTBACK, 98,000 byes, ya take 1,000 down....

I used the asyncpostback site example, but the Content-Length just keeps growing and growing and growing from 8 k to 100,000 k as your approach 300 clicks on headers or page numbers.

Is this a problem with that site's usage of the control?

I posted my findings on my blog here:
http://www.dotnetjunkies.com/WebLog/joshuagough/archive/2006/06/28/141278.aspx

Tony
July 03, 2006

# re: ATLAS UpdatePanel Experiments

Is the atlas: tag supposed to work in usercontrols (ascx)? If not, how can you use atlas in sites using WebParts?

Gagan
July 05, 2006

# re: ATLAS UpdatePanel Experiments

Hi guys,
Can anyone tell me how can i add user control inside the update panel i am really stuck in these.

Dan Bayley
July 07, 2006

# re: ATLAS UpdatePanel Experiments

there does seem to be an issue with nested updatepanels where the parent updatepanel on page contains a user control and the usercontrol contains child updatepanels.

It would seem that the parent update panel always updates and I can't find a way to disable or intercept it as a hack.

Has anyone else come accross this?

Hans
July 12, 2006

# re: ATLAS UpdatePanel Experiments

maybe somebody else will find this tidbit useful... it resolved 50% of my update panel problems.

altering the response buffer (i.e. response.writes) during an asynch postback seems to prevent update panels from refreshing.

Cheers!
Hans

mike
July 18, 2006

# re: ATLAS UpdatePanel Experiments

hi Guys,

just in case this will help anybody. I had problems with my update panel - it wasn't updating the page after partial postback, same error as Hans mentioned.

I finally found out that this line of code on my page was causing it: "<!-- DESIGNER CODE //-->"

Cheers,
Mike

Andrew
July 18, 2006

# 98,000 bytes?

Josh... There's a significant difference between 100,000 k and 100,000 bytes.. You're saying it took you 300 click to get you from 8.5k to 89k - not 8.5k to 100 Megs! ;)

Shahid
July 24, 2006

# re: ATLAS UpdatePanel Experiments

I have two pages and each page has a User Control. From the first page we can open the second page (first page shows all articles and it has a link "add new article".)

I would like the Update Panel on the First page, showing articles to be updated when we click on "Submit" button on the second page to add a new article so that the new article is also visible in the First page.
I read earlier post about using a hidden button, I have placed the button inside the Update Panel control but now how do I call it from the child form when its submit button is clicked?

Regards,
Shahid

choffman
July 25, 2006

# re: ATLAS UpdatePanel Experiments

I am trying to Load a UserControl dynamically when a button is pressed on a web form. This usercontrol is loaded into an UpdatePanel inside a <div>. I have 6 usercontrols dynamically loading into 6 updatepanels. I have 6 buttons outside of the UpdatePanels. I want the buttons to load the usercontrols into the update panels individually and mimic a UltraListBar using collapsible panel extenders from the atlas tool kit. Everything looks good at first when the page loads and all of the panels are collaped. When I open one of the panels with the button associated with the extender and panel, the usercontrol doesn't show up until I hit the refresh button on IE. I have triggers set up on each update panel and they are associated with a button and they are attached to the click event. I have googled this problem and haven't found a good answer or reason to this problem

ATLAS Forum Posts
August 03, 2006

# Nested UpdatePanel causes parent to post back?

Been playing with UpdatePanels all day, and after reading Rick Strahl's post here- http://west-wind.com/weblog/posts/4642.aspx

goystryk
August 24, 2006

# Custom Control to Force Full Postbacks in an Update Panel

I tackled the issue today of building a button control to force a full postback in an update panel. Seems to work all right. Thought I'd put my first cut of code (not completely tested) up for general interest:
Namespace UI.Controls

Public Class UpdatePanelPostbackButton
Inherits System.Web.UI.Control

Public Enum UpdatePanelPostbackButtonButtonType
Link
Button
End Enum

Private enmButtonType As UpdatePanelPostbackButtonButtonType

Public Event Click(ByVal sender As Object, ByVal e As EventArgs)

Protected Sub ButtonClicked(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Me.Page.Request.Form("__EVENTTARGET") = Me.ClientID.Replace("_", "$") Then
RaiseEvent Click(Me, EventArgs.Empty)
End If
End Sub

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Dim strJScript As String = "javascript:theForm.__EVENTTARGET.value='" & Me.ClientID.Replace("_", "$") & "';theForm.submit();"
Select Case Me.ButtonType
Case UpdatePanelPostbackButtonButtonType.Button
writer.Write("<input type=""button"" value=""" & Me.Text & """ name=""" & Me.ClientID & """ id=""" & Me.ClientID & """ onclick=""" & strJScript & """/>")
Case UpdatePanelPostbackButtonButtonType.Link
writer.Write("<a id=""" & Me.ClientID & """ href=""" & strJScript & """>" & Me.Text & "</a>")
End Select

End Sub

Public Property Text() As String
Get
Return Me.ViewState("Text")
End Get
Set(ByVal value As String)
Me.ViewState("Text") = value
End Set
End Property

Public Property ButtonType() As UpdatePanelPostbackButtonButtonType
Get
Return enmButtonType
End Get
Set(ByVal value As UpdatePanelPostbackButtonButtonType)
enmButtonType = value
End Set
End Property

End Class



End Namespace

pranav
September 07, 2006

# ATLAS UpdatePanels Experiments


Just while we're on the topic of multiple Update Panels, is there any way to change the following behaviour for the <UpdateProgress> Control.

I have 3 update panels on a webform.
Each has its own button within the panel
Each Panel is set to conditional mode
And Each UP has an UpdateProgress Control containing nothing more than a swirling animated gif.

The problem is that while the button clicks in each respective panel, only update that panel... they make the UpdateProgress section in all panels visible, for the duration of the call.

i.e.
Clicking UpdatePanel1.Button1 only causes UpdatePanel1 to re-render, but makes the following visible
UpdatePanel1.UpdateProgress1
UpdatePanel2.UpdateProgress2
UpdatePanel3.UpdateProgress3


What is the solution? i must have to keep all the panels mode=conditional.


Rick Strahl
September 07, 2006

# re: ATLAS UpdatePanel Experiments

From what I understand there's only a single UpdateProgress manager for the page, so even with multiple UpdatePanels you won't get focused updated information.

Same issue exists with the callback completion events on the PageManager - there's only one even that gets managed that handles the callback completion for ANY of the update panels and there's no context to know which one was completed.

This seems a fairly big oversight IMHO.

Hans
September 15, 2006

# re: ATLAS UpdatePanel Experiments


in FireFox, using javascript to call parent.__doPostback('mycontrol') starts the partial postback on the parent window, and you can see the UpdateProgress rotating Image, but it never stops rotating and the page never refreshes.

This works fine on IE and Opera - is this a known FireFox issue that the atlas team is working on?

Thanks in advance

Hans
September 15, 2006

# re: ATLAS UpdatePanel Experiments

"but it never stops rotating" :) ... I meant to say it never goes away ... you know what I mean!

AJAX UI
September 29, 2006

# ASP.NET Forums - Nested UpdatePanel causes parent to post back?


AJAX UI
October 13, 2006

# ASP.NET Forums - UpdatePanel + DataList (not updating)


sid
October 20, 2006

# re: ATLAS UpdatePanel Experiments

When i Use ajax update panel with two listboxes and button to add items from souce listbox
to destination. Everything works fine Until
Souce list box have items more than 100 with scrollbars.
Destination listbox starts to Flicker on each additem.

Any suggestions on how to remove the listbox flashing when first listbox is loaded with
scrollbar.

Thanks in advance

Reiner
November 30, 2006

# problem closing a page self.close atlas asp.net

Hi friends

I try http://ajax.asp.net/docs/tutorials/IntroductionUpdateProgress.aspx
but I add a button and the I put some Javascript code
I do not know why it does not work.

This code work very well without Atlas...

Any help please send a mail at reiner@tm.minabas.cu
Thanks
Reiner


protected void btbSalir_Click1(object sender, EventArgs e)
{
if (Request.QueryString["textbox"] != "")
{
string strScript = "<script>window.opener.document.forms(0)." + Request.QueryString["textbox"].ToString() + ".value = '";
strScript += txtSeleccion.Text.Trim();
strScript += "';self.close()";
strScript += "</"+ "script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "GridView_Seleccion", strScript);
}

Reiner
November 30, 2006

# problem closing a page self.close atlas asp.net

Hi friends

I try http://ajax.asp.net/docs/tutorials/IntroductionUpdateProgress.aspx
but I add a button and the I put some Javascript code
I do not know why it does not work.

This code work very well without Atlas...

Any help please send a mail at reiner@tm.minbas.cu
reinerra@gmail.com
Thanks
Reiner


protected void btbSalir_Click1(object sender, EventArgs e)
{
if (Request.QueryString["textbox"] != "")
{
string strScript = "<script>window.opener.document.forms(0)." + Request.QueryString["textbox"].ToString() + ".value = '";
strScript += txtSeleccion.Text.Trim();
strScript += "';self.close()";
strScript += "</"+ "script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "GridView_Seleccion", strScript);
}

Thirumalai
January 17, 2007

# re: ATLAS UpdatePanel Experiments

Hi friends,

I have an updatepanel, in this I have asp:table control. I am buiding the table by runtime only as per the user requirement.

I have to refresh the table when the user select some options like date, listbox, button which is located outside of the update panel and I have some of the controls which is located in the updatepanel.table itself (building at runtime).

I did the coding like updatepanel.update(), but it is not working.

Can you please give me a solution for this.

Thanks friends,
Thirumalai

Marc
February 01, 2007

# re: ATLAS UpdatePanel Experiments

<Triggers>

<atlas:ControlEventTrigger ControlID="btnRefresh" EventName="Click" />

</Triggers>

What if the btnRefresh is placed in the DetailView or GridView, what would you do? Please help! Thanks!

Marc

Ravinder Singh bisht
February 16, 2007

# re: ATLAS UpdatePanel Experiments

Hi...
i m not able to show my records on a Datagrid on a Button click event.It is working fine with my other forms with Gridview.I m also using a separate javascript file.
Datagrid is tagged inside the Update panel using Atlas.

plz find some solution
Urgent...

Ravinder Singh Bisht

ASP.NET Forums
May 18, 2007

# UpdatePanel + DataList (not updating) - ASP.NET Forums


ASP.NET Forums
June 02, 2007

# Nested UpdatePanel causes parent to post back? - ASP.NET Forums


Ben van Enckevort
July 28, 2007

# Your unconditional update problem...

Hi there

Sorry, i haven't read through all the comments, but i assume you haven't found the solution because i did a search on this page for "children".

I just ran into this problem myself (was driving me crazy) and discovered the option on the UpdatePanel - "ChildrenAsTriggers" (pretty self explanatory).

That should fix the it if you set it to False or have i misunderstood the problem?

amit gupta
February 14, 2010

# re: ATLAS UpdatePanel Experiments

i have problem,

i have dropdownlist and textbox on my page. now i want to set a textbox text with the value of dropdownlist on SelectedChangedIndex event. but i want to use here updatepanel for that.
how can i set a textbox text in each selected item value of dropdownlist using updatepanel.

the code is below mentioned:

<td class="style7">
<asp:DropDownList ID="ddlLeaveType" runat="server"
onselectedindexchanged="ddlLeaveType_SelectedIndexChanged"
AutoPostBack="True"></asp:DropDownList>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtdescription" runat="server" Enabled="false" Width="206px"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlLeaveType" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>

and cs code
protected void ddlLeaveType_SelectedIndexChanged(object sender, EventArgs e)
{
txtdescription.Text = ddlLeaveType.SelectedValue.ToString();
}
pls help.

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2025