Showing posts with label dynamically. Show all posts
Showing posts with label dynamically. Show all posts

Wednesday, March 28, 2012

UpdateProgress subcontrols modification

I have the following code in place on my page. What I would like to do is to dynamically set the
lblProcessingRequest Text property during page load, because the site have some local language
customization build in.

I have tried a lot of things, but can't manage to get it to work.

<asp:UpdateProgressID="UpdateProgress"runat="server"AssociatedUpdatePanelID="UpdatePanel"DisplayAfter="100"DynamicLayout="False">

<ProgressTemplate><imgsrc="images/ProcessAnimation.gif"align="absMiddle"> <asp:labelID="lblProcessingRequest"Text="Processing request..."runat="server"Font-Bold="True"></asp:label></ProgressTemplate></asp:UpdateProgress>

The content is a template, so you can't immediately get at the controls like you normally can.

The template is instantiated during PreRender, so you should be able to hook into the Page's PreRenderComplete event, then do a FindControl on the update progress to get to the label:

private void PreRenderCompleteHandler(object sender, EventArgs args) {
Label l = (Label) UpdateProgress.FindControl("lblProcessingRequest");
l.Text = ""; // some localized text
}

Whenever you do this sort of thing, please, please be wary of ViewState. You should disable ViewState on that label, or you will be persisting viewstate data that doesn't need to be. If you are doing this for many labels on the page it could really add up to a problem. Read my (lengthy) article on ViewState, linked in my signature, if you have time.


ProtectedSub Page_PreRender(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.PreRenderTryCType(UpdateProgress.FindControl("lblProcessingRequest"), Label).Text ="Some local Text"
Catch exAs Exception
EndTryEndSub

Sorry to say that this doesn't work. The control is not found. Couldn't this be because the label only is visible during the UpdateProgress, and at all
other time is hidden? I even tried hooking the control in the UpdateProgress PreRender method, but that didn't work eighter...


Ok, was I litte to hasty here.

Protected

Sub Page_PreRenderComplete(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.PreRenderComplete

Hooking into the PreRenderComplete works fine!

UpdateProgress within treeView

hi...

i have treeView(populate onDemand) in updatePanel, and i want to add updateProgress animation or message, dynamically near to the selected node(parent node), someone have an idea how to implement that?

thanks...

Hi,
???Here are some sample codes about asp:TreeView working with asp:UpdateProgress for your reference.
??? <div>
<asp:UpdatePanel ID="UpdatePanel8" runat="server">
<ContentTemplate>
<asp:TreeView ID="tv" runat="server" OnSelectedNodeChanged="tv_SelectedNodeChanged">
<Nodes>
<asp:TreeNode Text="File" Value="File"></asp:TreeNode>
<asp:TreeNode Text="Edit" Value="Edit"></asp:TreeNode>
<asp:TreeNode Text="View" Value="View"></asp:TreeNode>
</Nodes>
</asp:TreeView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" runat="server"
AssociatedUpdatePanelID="UpdatePanel8"
DisplayAfter="2000"
DynamicLayout="False">
<ProgressTemplate>
UpdatePanel1 is updating now!
<input type="button" id="AbortCallbackButton" value="Abort" onclick="AbortCallback()" />
</ProgressTemplate>
</asp:UpdateProgress>
<br />
This is text after the UpdatePanel and UpdateProgress controls.
<script type="text/javascript">
function AbortCallback()
{
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
}
</script>
</div
protected void tv_SelectedNodeChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(10000);
}
Wish this can give you some helps.

Monday, March 26, 2012

Updating the user interface on a web form BEFORE UpdatePanel finishes

Hello

does anyone know if it is possible to dynamically alter the contents of a control (e.g. a label) so that it updates BEFORE the UpdatePanel finishes its asynchronous operation? An example might be for a progress bar. I have a process which takes up to 5 minutes, but which generates an event as it progresses. I want to update a control each time this event gets triggered, but because I update the user interface in the async part, it doesnt do anything until it has completed.

For example imagine I have a button with an OnClick event inside an UpdatePanel, alongside a label in the UpdatePanel.
WHen I click the button, if I loop through one hundred objects, andwish to update the contents of the label as I do this (i.e. 'On itemnumber: x'), how is this done?

Thanks

Tom.

Have you tried calling the .Update() method on your update panel in the loop? That may or may not work.


Take a look at this:http://encosia.com/2007/10/03/easy-incremental-status-updates-for-long-requests/


I did try this within the asyn call, but nothing happens. I am assuming that whatever happens is built into a long string of javascript or suchlike which is not executed until completion.

That's right. Output buffering prevents anything along those lines from working. Using an iframe lets you work more interactively.

Saturday, March 24, 2012

Upload control in a Wizard in an Update Panel. How to add the trigger dynamically?

I have an update panel surrounding a Wizard control. One of the steps in that wizard is that the user can upload photos. So what I want to do is add a trigger to force a full postback on the upload step.

Is this at all possible? I'm having troubles obtaining the correct ControlID to add on the trigger...

ctafield:

I have an update panel surrounding a Wizard control. One of the steps in that wizard is that the user can upload photos. So what I want to do is add a trigger to force a full postback on the upload step.

Is this at all possible? I'm having troubles obtaining the correct ControlID to add on the trigger...

Hi.

FileUpload is not supported with ASP.NET AJAX .because that you cann't use it and you cann't find it with ControlID's!


Create a Button Control and set this as a PostBack trigger forupdatePanel. In the Button Click event save the file from File uploadcontrol.

anishdevasia:

Create a Button Control and set this as a PostBack trigger for updatePanel. In the Button Click event save the file from File upload control.

Thank you for the suggestion. I'll give it a go!