Showing posts with label execute. Show all posts
Showing posts with label execute. Show all posts

Monday, March 26, 2012

Detecting which UpdatePanel was updated for endRequest

I've got an issue where I'm trying to execute some javascript when a specific UpdatePanel on my page (I have about 5) is updated. I've added event handlers for initializeRequest and endRequest. I know that I can get the ID of the element that *caused* the postback - but I really don't want that. I need the id of the UpdatePanel that is being updated.

Then endRequest method that gets called after an UpdatePanel gets updated is called for any and all UpdatePanels - this ambiguity makes it difficult to know which UpdatePanel caused this request.

Any ideas?

Cheers,

Bobby

The endRequest event doesn't have the information you want. If you handle the pageLoaded event, the args parameter that gets passed in to your handler has a panelsUpdated property which returns an array containing the panels that were updated.

Design Question (Looking for your opinions)

I have a page that I need to call a method from my business tier. This method ussually will execute and complete quite quickly.

But because we are making and call to an external service. There are times where the network could be slow or the request gets sent but nothing comes back.

What I want to do is use ajax to make a call to the Business Layer. If it takes longer than say 5 secs. I want the ajax call to timeout and redirect to another page. Leaving

the process to complete on it's own (It doesn't return anything). The status of the "Async Job" will be checked somewhere else by the user.

Would this be an exceptable means of dealing with a long running task? We don't need the user to wait until it's complete.

Check out this for one example on long running queries...

http://www.west-wind.com/atlas/LongProgress/LongProgress.aspx

Maynot be exactly what you are looking for but...


That's a great example. Thank you very much.. I got it working :)

If I make the async call time out and call the function like so onTimeOut fires properly. If an error happens it goes to this method as well.

PageMethods.SendInfo(onComplete,onTimeOut);

If I make the async call error out OR time out and call the function like so PageMethods.SendInfo(onComplete,OnError,onTimeOut); both

timeouts & errors got the onError method.

Wednesday, March 21, 2012

Declarative xml-script from UpdatePanel

Is there a way to insert (and execute) declarative xml-script from UpdatePanel?

For example following code works if control is visible, so xml-script is loaded with the page. If control is hidden, or created at run time xml-script is not executed.

test.aspx:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" %>
<%@dotnet.itags.org. Register TagPrefix="uc" TagName="Control1" src="http://pics.10026.com/?src=~/WebUserControl.ascx" %>
<script runat="server">
void Button1_Click(object sender, EventArgs e)
{
c1.Visible = true;
}
</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="ScriptManager" runat="server" EnablePartialRendering="true" />

<atlas:UpdatePanel ID="p1" runat="server" Mode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<uc:Control1 ID="c1" runat="server" Visible="false" />
</ContentTemplate>
</atlas:UpdatePanel>

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

WebUserControl.ascx:

<%@dotnet.itags.org. Control Language="C#" ClassName="WebUserControl" %>

<div id="panel">Click the button to Hide me</div>
<input id="hideButton" type="button" value="Hide" />

<script type="text/xml-script">
<page xmlns="http://schemas.microsoft.com/xml-script/2005">
<components>
<control id="panel" />
<button id="hideButton">
<click>
<setProperty target="panel" property="visible" value="false" />
</click>
</button>
</components>
</page>
</script>

hello.

well, where's your panel control? if it's inside a user control, then you've already found your problem: the user control is a naming container class. this means that controls declared inside it will have a different client side id (it will be composed by the usercontrol id and the control id).


I thought client side id only changed for webform controls. This panel is just a plain <div>.

And if I just make user control visible from the start, it works, xml-script executes.


hello.

yes, if it's an html control, then you're right. not sure about the visibility...can you show me the div declaration that you have in the user control?


The div declaration is actually in the code above:<div id="panel">Click the button to Hide me</div>

I choose to hide div just for sample sake, it can be any xml-script.

Anyway, I recall now, javascript doesn't execute either, when it's inside control template and then the control instantiated inside update panel. The only way is to use RegisterXYZScript(...). But RegisterXYZScript(...) doesn't work for xml-script.

When using ScriptManager RegisterControl it places xml-script inside of that <xmlScript> tag at the end of update panel's <delta> response. I think it executes it, but there beside RegisterControl I didn't find any more methods to generate xml-script.

I know there is a way to write an ExtenderControl, and use ScriptTextWriter to generate xml-script. I haven't tried that yet.