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

Monday, March 26, 2012

Intellisense not updating UpdatePanel changes until...

I've just started using ASP.Net AJAX 1.0 in Visual Studio 2005 (Using VB.Net code editor). I've noticed that when I make a control change within an UpdatePanel (e.g. adding a new server control, or changing the ID of an existing server control), the intellisense in my code file is not updated until I close and reopen the .aspx file.

Is there a way to force this to refresh without having the close/reopen the .aspx file?

Thanks!

--Michael

Have you installed SP1 for VS 2005 and the Vista Update for that (if you are running vista)?


I'm not running Vista, and I have installed SP1.

Thanks


The lastest Visual Studio hotfix addressing intellisense issues has fixed the issue for me,

https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=9436

Intended behaviour for updateProgress??

I have 2 updatePanel, one nested inside another and 2 updateProgress. The 1st updateProgress is inside the outer updatePanel but outside the inner updatePanel. The 2nd updateProgress is inside the nested 2nd updatePanel.

When I click a button inside the 2nd nested updatePanel, both updateProgress controls display. Is this the intended behaviour?

UpdateProgresses aren't tied to an update panel unless you set them to be using the AssociatedUpdatePanelID property.

I have posted the code to duplicate this issue herehttp://forums.asp.net/thread/1556109.aspx

Has anyone heard anything about a fix for this?

interesting issue with updatepanel and absolutely positioned div

Hi,

Earlier this evening, I ran into an interesting problem. To be honest, I'm not sure if it is purely ATLAS related or not, but when I removed the UpdatePanel around that section of code, it worked. The basic description is that when I moused over textboxes in my gridview, I could only select them when my mouse pointer was directly over the very top edge of the textbox. This happened where ever an absolutely positioned div with no content was covering it (the div style was position: absolute; z-index: 1; width: 100%; height: 100%; top: 0; left: 0;). Text and radio buttons in the same area were unaffected, as was a multi-line textbox.

Here's the detailed description:

On part of my page, I have a gridview and save button in an UpdatePanel (this is because the top of the page is a search form for populating the gridview and resulting form). Because the gridview is a form to be filled out, I have textboxes directly in the item templates for some of the columns. I also have a radiobuttonlist in each column, and a couple of plain old bound text columns. In that same UpdatePanel, I have another UpdatePanel for displaying some information and prompting the user to confirm or cancel the save. Largely for styling control, I decided to implement this confirm dialog as a div in an update panel. Wrapped around the outside of this UpdatePanel is an absolutely positioned div. The idea is that I can then style the confirm dialog in such a way that I can have a transparent .gif as the background image. This way, the user can see the data underneath the confirm dialog, but is unable to click on any of it -he/she must click one of the confirm dialog buttons.

Here's the basic code:

<atlas:UpdatePanel ID="up1" runat="server" RenderMode="inline">
<Triggers>
...
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server">

<div style='position:absolute; z-index: 1; width: 100%; height: 100%; top: 0; left: 0;'>
<atlas:UpdatePanel ID="upConfirm" runat="server" Mode="Conditional" RenderMode="inline">
<Triggers>
...
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlConfirm" runat="server" Visible="false">
<div style='width: 100%; height: 2000px; background: url(images/transparent.gif);'>
<div style='position: absolute; top:10%; left: 25%; padding: 10px; border: solid 3px green; background-color: #fff;'>
<p>
...
</p>
<p>
<asp:Button ID="btnConfirm" runat="server" Text="OK" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</p>
</div>
</div>
</asp:Panel>
</ContentTemplate>
</atlas:UpdatePanel>
</div>
gridview and other stuff is below but within up1
...

It worked beautifully other than the problem described at the top. I eventually fixed it by removing the height style on the div wrapping the confirm dialog's UpdatePanel. I luckily stumbled upon the solution when the gridview got filled with enough data to force a page scroll, and I noticed that the textboxes below the absolutely positioned div (height: 100%) worked normally. Because a div inside the UpdatePanel had the transparent background image, width, and height set, the page still functioned as intended.

My question is: has anyone else run into this? What causes textboxes to be only selectable by what appears to be the top pixel? Also, I should mention that if there was text in the textbox, the textbox was selectable as normal where ever there was text. So if the left half of the textbox contained text and the right half didn't, the left half was selectable normally, but when mousing over the right half, I could only select the textbox by clicking on its top border.

If need be, I can try to come up with some code to replicate it. It will take some doing, though, because everything is domain level objects in the code behind populating the gridview, etc.

Chris

Forgot to mention that this occurred in IE7. Not sure about IE6 or Firefox.

Hello All,


I am facing problem regarding Atlas.
I have install the AtlasSetup.msi in my .NET framework 2.0, and i open the new Atlas Website.....
Let me first explain the my senario,

I have data grid(5 colunm datagrid) on my Page. It's First Colunm is LinkButton whose text property contain the ID. As i click on the this LinkButton, the Data against ID (Linkbutton.Text) are move to the textboxes, so that u can edit the Values and click on Update Button to update the data in datagrid.

So i use atlas and put the datagrid and textBox in UpdatePanel
I wrote the trigger also as below
<Triggers>
<atlas:ControlEventTrigger ControlID="btnUpdate" EventName="Click" />
</Triggers>

but i found "Unknown error" alert box , as i click on Update Button.
Please Suggest me.... the reason behind this Error, Please Suggest me how to rectify this error.

I search in Atlas forum and Come to Known that if u have any special chararter in title like <title>Ajax & Page</title>
then u got this alert error message.
Or
if the session got expire, then also this error encounter.
in my case ... title is correct as well as my application session are also working perfectly.

Please, give me the suggest to come out from this problem.


with regards
Tarun Sinha


Here's another twist: in IE6, dropdownlists appear to be immune from the transparent gif. They show above it and are selectable. I even put a solid colored gif to be sure, and the only thing that appears above the gif are the dropdownlists! Anyone know why?

CSS styling (including z-index) doesn't seem to have an effect. I had to move them into an UpdatePanel and disable/enable them based on what was going on in the page. Textboxes, radiobuttonlists, gridviews, buttons, labels, and literals all end up under the image.

Of course, I just today read about the Modal Popup control, but for my purposes here, keeping everything on the server-side and being able to completely control what's in my "popup" (including buttons) would be easier, especially at this point.

Interesting problem with UpdatePanel

This one really puzzled me, and I thought I would share it with others because it's was really painful to find the problem.

The issue was, I have a composite control that include an UpdatePanel, inside that UpdatePanel there was a TextBox and the TextBox had an event handler for text changed, since AutoPostBack was true whenever the control loses focus it posts back and triggers the event, that was and is working fine.

I did the exact same thing on another composite control, problem was, the event was not firing

Nothing was wrong with it, the even was properly defined. I tried placing the TextBox outside the UpdatePanel and it would work fine. However, on the other control it was working inside the UpdatePanel.

Both UpdatePanels had been set the same.

I tried adding a checkbox to the UpdatePanel that wasn't working and it fired its events fine.

Beyond confused, I just copied the entire code that was working on the other control, only that adding the TextBox to the new UpdatePanel, oh surprise, it worked.

So, what was different? the only properties that were set differently were related to the appearance of the control.

But, on my TextBox (the one that wasn't working) I had set the ID with a + sign in it (I was using it as a separator for other reasons). When I replaced the + sign by a @dotnet.itags.org. it worked.

So, the UpdatePanel does not like a + sign on any of its children controls and if it finds one that control won't trigger any events.

I am not sure if this is a bug or it's related to the script generated for the postback, where the + sign is making the script to send a wrong info to the server.

In any case, it was really difficult to find the bug and I think the UpdatePanel should throw an exception if a + sign is included in any of its children's controls ID.

I thought I would share this in case someone goes through the same pain.

Use Asynchronous Postback

http://www.asp.net/AJAX/Documentation/Live/tutorials/ExclusiveAsyncPostback.aspx

Saturday, March 24, 2012

InverseTrigger?

Does such a thing exist yet? I want to trigger a full postback sometimes.
The usual scenario, is that I have the UpdatePanel around a grid to make sorting etc async.
Then, I want a link on the grid to redirect me to another form.
We use our own form loading mechanism, so it has to invoke a server-side function to replace the currently loaded form, which is of course around the UpdatePanel again (outside / parent).

How would this be possible?

hello.

if you want to have a full postback started by an element placed inside the updatepanel, then the easiest way to achieve that is to add a button, set its display style to none, and then call the click method over that dummy button.


Thanks but that won't cut it.
It cannot be done since the postback will be triggered by a button inside a repeater, and the buttons have their arguments.
It would be a hack to have a button which is hidden as well, and it wouldn't do me any good.
I want to handle the button's event like I usually would, not some other event (hack, duplicate code).

And if I really wanted to do that, I could just made the page implement IPostbackEventHandler and submit the form myself (without invisible button hack).

Please tell if UpdatePanel will have InverseTrigger in future releases. It is crucial if you have a LinkButton inside UpdatePanel that you know will do something with control outside it!

--

I made something named PopupCallback feature for popups calling a server side method on it's opener.
I can probably use that same thing to solve my problem. But UpdatePanel should really have this stuff built in!

Thanks in advance!

EmilChristopherMelar:


It cannot be done since the postback will be triggered by a button inside a repeater, and the buttons have their arguments.

well, not easy then. unfortunately, all the controls placed inside an updatepanel will only be able to produce a partial postback since those calls will allways be intercepted by client side. that's why i suggested the hack (which is really the easiest way to get a full postback from within an updatepanel)


I understand, but wouldn't it be a way to change the UpdatePanel to work this way as well? I think it is a requested feature.

Would it be possible to extend certain controls or tag them somehow with an extender or whatever to trigger a full postback / bypass UpdatePanel? I cannot use UpdatePanel since my page loading mechanics are not URL based, but post based ( I have my reasons ;-) ).
* bump *

Invoke an UpdatePanel update from client script

I'm writing an application which is predominantly a client-centric application but I need to update a part of the page from a client script action. What is the correct way to do that? I presumed that you simply set the UpdateMode of your UpdatePanel to Always and then implemented ICallbackEventHandler on the page to do the async postback. I've done that, but my UpdatePanel is not updating... help :)

In my ClientCallback, I'm essentially rebinding the control that sits inside the UpdatePanel and then explicitly calling Update() on the UpdatePanel... but nothing.

Hi digory,

http://encosia.com/2007/07/13/easily-refresh-an-updatepanel-using-javascript/

Is this what you are looking for?

Wim.


It is. I was just trying that solution as you posted and it works fine. Thanks! Smile

Wednesday, March 21, 2012

Is it different to use serveral small UpdatePanels or use one UpdatePanel with entire page

How many data with processed on server and how many data will response to client?

I think multiple small UpdatePanel should surely be better.

SeeHERE.

dflying:

UpdatePanel just updatesALL the controls in its ContentTemplate from server, which may be very low efficient.

Is it possible to add a ScriptManager to a page dynamically?

As per the title, is it possible to add a script manager to a page from code?

I have it working OK if the UpdatePanel is also created in code (explicitly after the script manager is created) but not if the UpdatePanel is defined in the aspx template. In that case, if I put my code in "OnInit", the page raises an exception saying that "the Script manager needs to be added (to the page's control tree) before the UpdatePanel", whereas if I move the code to "OnPreInit" then the controls collection is not even created yet.

In other words, adding the Script Manager "OnPreInit" is too early but adding it "OnInit" is too late IF the UpdatePanel is defined in the aspx.

The reason I'm asking is that it would be nice to be able to write controls that could detect if the Page they are hosted in has a Script Manager (or proxy?) and if not, and if they need to use AJAX, then the control can add one, theus removing this dependancy and "knowledge of the implementation" from the client using the control.

Any ideas?

Many thanks

I use a simple workaround-- add a property that says UseAJAX (boolean), and in the XML documentation for the control I say that if the control is on a page with a ScriptManager, or in an UpdatePanel, to set this value to true.

Then the control takes this into account when instantiating and building the control structure, as well as when registering scripts.


OK thanks, that would be OK - obviously this is something you've already come across and worked around.

I did have some ideas on these lines myself, like having an IAjaxControl interface that had a method like "EnableAjax()" that would create & append the UpdatePanels to the control - one of the reasons being that the UpdatePanels, once created and added to the control tree CANNOT be moved so if the client wants to take the control and move it to another part of the tree then it will cause an exception. Having the method, rather than a property, gives the client some control as to WHEN to trigger the creation of the Ajax components (ideally after the control tree is "set in stone").

With hindsight, I think I like your idea of a simple boolean property (but defined in the IAjaxControl interface) and always create the UpdatePanels in the OnLoad (if the boolean is true) rather than beforehand - hopefully then the control tree is final and we are safe to do it, and the GUI designer can support the boolean property withought the need for coding from the client.

I felt the interface was needed for scenarios like where a different control CONTAINED your Ajax enabled control - it too would then need to support the property (and pass it down to your control it was containing).


Did you find a solution (Like you, I try the OnInit and the PreOnInit) ?

All my pages inherits the same class (let's say PageAncestry). I want to add the scriptmanager with code in PageAncestry so all my pages will automatically be able to use ajax.


After some google search, I finally found a solution on this page http://www.capdes.com/2007/02/microsoft_office_sharepoint_se.html

Add the ScriptManager in the PreInit at the HtmlForm first position :

Private Sub Page_PreInit(ByVal poSender As Object, ByVal poArguments As System.EventArgs) Handles Me.PreInit

' Get current ScriptManager if exist
Dim oScriptManagerAjax As ScriptManager = ScriptManager.GetCurrent(Me)
' If not exist
If oScriptManagerAjax Is Nothing Then
' Create one
oScriptManagerAjax = New ScriptManager
' Get page form
Dim oForm As HtmlForm = Me.Form
' If form present
If Not IsNothing(oForm) Then
' Add it at first position
oForm.Controls.AddAt(0, oScriptManagerAjax)
Else
' Manage if not (impossible to use Ajax)
End If
End If


End Sub


Hmm, from what I was saying:

"whereas if I move the code to "OnPreInit" then the controls collection is not even created yet."

and yet, in "PreInit" you have code:

oForm.Controls.AddAt(0, oScriptManagerAjax)

Are you sure thius works? According to my original post "oForm.Controls.Add" should have raised an exception as the "Controls" collection is not yet created. Are you sure your code works?

My page also uses a MasterPage - does yours? Does that make a difference (i wonder??)

I'll give it a try tomorrow. Thanks for the post :)


Yes it's working for me.

I don't have a master page, so I don't know if it's working with.

The most important thing is theControls.addat(0, it put the ScriptManager before all other controls define in the form (even the one in design). It's not working if you use only Controls.add


I'm pretty sure that "Controls.AddAt(0..." is what I was using before - as I said though, I believe the "Controls" collection was null at PreInit.

Anyway, I will try again and post my results :)


No mate, this just doesn't work, not in C# anyway.

The isssue is as before but I was mistaken, it's not the Control collection that is not created, it is the Form object itself.

Here is my ASPX Template:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Page2.aspx.cs" Inherits="Page2" %><!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"> <div> Page 2<br /> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>

And here is my code behind:

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass Page2 : Page{protected override void OnPreInit(EventArgs e) {// Pop a script manager on the page if one does not yet exist. ScriptManager scriptManager = ScriptManager.GetCurrent(this);if (scriptManager ==null) { scriptManager =new ScriptManager(); HtmlForm form =this.Form;if (form !=null) form.Controls.AddAt(0, scriptManager); }base.OnPreInit(e); }protected void Button1_Click(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToLongTimeString(); }}

As you see here, if "form" is null we can't add the script manager, and this.Form IS null at "PreInit":

if

(form !=null)
form.Controls.AddAt(0, scriptManager);

The only way I could get this to work is doing it in the "Onint" where the ScriptManager is created first and then the UpdatePanel created IN CODE afterwards (NOT defined in the aspx). Unfortunately, defining the Update Panel in the aspx means that "Oninit" is too late to add the script manager, but "PreInit" is too early as the form is not yet created.

Please tell me I'm wrong about this - how have you got this to work? I don't get it. Can you post your ASPX & VB code?



Not works!!!

Obviously the code is in the OnInit andnot in OnPreInit at http://www.capdes.com/2007/02/microsoft_office_sharepoint_se.htmlSmile

I think the msdn documentation not correct about the preinit event, this is an excerpt of my offline msdn library (seeit online):

PreInit

Use this event for the following:

Check theIsPostBack property to determine whether this is the first time the page is being processed.


Yes stmarti, although I think the documentation is (technically) correct in that you can CREATE controls at OnPreInit but you CANNOT add them to your Form, as it does not yet exist!

If you do this in OnPreInit:

Label label =newLabel();
label.Text ="Hello PreInit world";
this.Controls.Add(label);

and you'll see that the label ends up rendering AFTER ALL HTML MARKUP!!!! (ie was added to the control tree FIRST, then the Form was Added AT(0) with all real content then added to the form - leaving your poor Label "out in the cold".

So if the Form is not yet created at OnPreInit, I can't see how the VB code posted above could work.


Just tested this:

Private Sub Page_PreInit(ByVal poSender As Object, ByVal poArguments As System.EventArgs) Handles Me.PreInit

' Get current ScriptManager if exist
Dim oScriptManagerAjax As ScriptManager = ScriptManager.GetCurrent(Me)
' If not exist
If oScriptManagerAjax Is Nothing Then
' Create one
oScriptManagerAjax = New ScriptManager
' Get page form
Dim oForm As HtmlForm = Me.Form
' If form present
If Not IsNothing(oForm) Then
' Add it at first position
oForm.Controls.AddAt(0, oScriptManagerAjax)
Else
' Manage if not (impossible to use Ajax)
End If
End If

End Sub

And it works.... only when you havealreadya scriptmanager in the aspx. Obviously this code in real do nothing special because:

- if you have already a scriptmanager on the page the code does nothing, and your page is just fine...

- if you have not a scriptmanager in the aspx, the following code

' Add it at first position
oForm.Controls.AddAt(0, oScriptManagerAjax)

neverwill be executed because oForm is null in preinitSmile! Anyway your page will throw exception and cry for a scriptmanager...


VR2:

Yes stmarti, although I think the documentation is (technically) correct in that you can CREATE controls at OnPreInit but you CANNOT add them to your Form, as it does not yet exist!

You are right. Technically it's correct. The doc (at least this entry in msdn) suggest preinit for creating dynamic controls, and init for setting control properties. This is not true for the form's controls, would be nice a remark about it in the future.


I try your C# code and it's not working :(

But I found the difference with my vb code :) (I can't post it, it's included in a bigger class)

I use FindControl to search the Form !

Just change the OnPreInit in your code by this one and it's workingBig Smile
protected override void OnPreInit(EventArgs e) { ScriptManager scriptManager = ScriptManager.GetCurrent(this);if (scriptManager ==null) { scriptManager =new ScriptManager(); Control oControl =this.FindControl("Form1");if (oControl !=null) { oControl.Controls.AddAt(0, scriptManager); } }base.OnPreInit(e); }

It works!!! Like thisBig Smile:

protected override void OnPreInit( EventArgs e )
{
HtmlForm form1 = ( HtmlForm )this.FindControl( "Form1" );

ScriptManager temp = new ScriptManager( );
temp.EnablePageMethods = true;

form1.Controls.AddAt( 0, temp );

base.OnPreInit( e );
}

Great work gbarry! The problem solved and the answere for:

Is it possible to add a ScriptManager to a page dynamically?

is:yes! Yes

Is it possible to add a ScriptManager and/or UpdatePanel to a MasterPage from a ContentPag

I would on like AJAX on one content page and want to add an UpdatePanel to the MasterPage and wrap a UserControl that is being loaded from the MasterPage in that UpdatePanel all from the ContentPage. Is it possbile to do this? I have some code but it is not working.

protected override void OnPreInit( EventArgs e ) { ScriptManager sm =new ScriptManager(); sm.ID ="ScriptManager1"; Master.Controls.Add( sm ); UpdatePanel panel =new UpdatePanel(); panel.ID ="upMaster"; panel.ContentTemplateContainer.Controls.Add(this.Controls[0] ); AsyncPostBackTrigger trig =new AsyncPostBackTrigger(); trig.ControlID ="btnDelete"; trig.EventName ="Click"; panel.Triggers.Add( trig ); Master.Controls.Add( panel );base.OnPreInit( e ); }

I changed my code and now can get the page to load but now I dont see my usercontrol on the masterpage

protected override void OnPreInit( EventArgs e ) { UpdatePanel panel =new UpdatePanel(); panel.ID ="upMaster"; UserControl uc = (( UserControl )Master.FindControl("CartSummary1" )); panel.ContentTemplateContainer.Controls.Add( uc ); panel. //AsyncPostBackTrigger trig =new AsyncPostBackTrigger();//trig.ControlID = "btnDelete"; //trig.EventName = "Click"; //panel.Triggers.Add( trig ); HtmlForm form1 = ( HtmlForm )Master.FindControl("Form1" ); form1.Controls.Add( panel );//Master.Controls.Add( panel );base.OnPreInit( e ); }

Yes,It is possible.

Do it like this:

MasterPage.master:

<%@. Master Language="C#" %>
<%@. Register src="http://pics.10026.com/?src=UserControlA.ascx" TagName="UserControlA" TagPrefix="uc1" %>

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

<script runat="server">

</script>


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:UserControlA ID="uc1" runat="server" />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
<asp:contentplaceholder id="ContentPlaceHolder2" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

Default.aspx:

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString();
}


protected void Page_PreInit(object sender, EventArgs e)
{
HtmlForm form1 = (HtmlForm)Master.FindControl("form1");
ScriptManager sm = new ScriptManager();
sm.ID = "ScriptManager1";
form1.Controls.AddAt(0, sm);

UpdatePanel panel = new UpdatePanel();
panel.ID = "upMaster";
UserControl uc = ((UserControl)Master.FindControl("uc1"));
panel.ContentTemplateContainer.Controls.Add(uc);
form1.Controls.Add(panel);
}

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div style="display:none;"><asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button1_Click" /></div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<script type="text/javascript" language="javascript">
function doclick(){
$get('<%= Button2.ClientID%>').click();
}
</script>
<asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="false" OnClientClick="doclick();return false;" />
</asp:Content>

UserControlA.ascx:

<%@. Control Language="C#" ClassName="UserControlA" %>

<asp:TextBox ID="TextBox1" runat="server">TextBox in UserControlA</asp:TextBox>

Best Regards,

Is it possible to cancel update of an UpdatePanel?

Hi there,

I have an UpdatePanel in my .aspx page. I have a timer control which "ticks" on regular intervals (say, every minute or every 20 seconds) and causes the panel to update (which is specified via the UpdatePanel's Triggers collection).

On the server side, I check whether there have been any changes since last update and whether I need to actually update the panel. If no changes, I don't want the UpdatePanel to flush the same contents to the client browser as it already has. So what I want is kinda "cancel" the UpdatePanel under certain circumstances.

How can I achieve that? Thanks in advance.

Hi,

You should set UpdatePanel.Mode = Conditional, remove all triggers from your UpdatePanel and update your panel programmatically in the tick event.

 <atlas:UpdatePanel ID="udp1" runat="server" Mode="Conditional"> <ContentTemplate><%-- Put your content here--%>
 </ContentTemplate> </atlas:UpdatePanel> <atlas:TimerControl ID="tc1" runat="server" Interval="60000" OnTick="tc1_Tick" />
protected void tc1_Tick(object sender, EventArgs e){if (ThePanelMustBeUpdated())this.udp1.Update();}

Oh.. right... it's so simple..

Thank you very much

Is it possible to catch a GetPostBackEventRefrence in an UpdatePanel?

I've got a custom gridview control where inside the RowDataBound event, I am setting an attribute to the row to allow the user to just click anywhere on the row, instead of clicking the 'Select' command.

This works fine, but it does a postback. Is it possible to capture that in the updatepanel?


e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, "Select$" + e.Row.RowIndex.ToString()));

There should be no difference in behavior whether you're in an UpdatePanel or not. The only constraint I can think of is that you can't alter anything that isn't contained in an UpdatePanel during the PostBack.

So, if you can catch the GetPostBackEventReference normally, you should still be good in an UpdatePanel.


I have the same problem. It works perfectly without the updatepanel, but when the gridview is placed inside the update panel, it does not update when the user clicks the row.


Hi,gidikh

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Thanks


I figured out my problem. I was updating a formview outside of the updatepanel. As soon as I put that formview into an updatepanel of it's own, everything worked as it should.