How to access templated controls in user control?

A

Ajak

Hello,

I am making a user control containing ajax updateprogress control as below:-

<%@ Control Language="vb" AutoEventWireup="false"
CodeBehind="AjaxProgress.ascx.vb"
Inherits="sbmb.AjaxProgress" %>

<span id="spanTag" runat="server" class="ajaxprogress">
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Image ID="imgLoading" ImageAlign="AbsMiddle"
ImageUrl="~/imej/loading.gif" runat="server" />
<asp:Label ID="lblMessage" runat="server" />
</ProgressTemplate>
</asp:UpdateProgress>
</span>

The purpose is just to wrap updateprogress with span and assign cssclass
"ajaxprogress" to force it to be positioned inline.

In codebehind, I write a property LoadingMessage to set the text of
lblMessage like this:-

Method 1:
CType(UpdateProgress1.Controls.FindControl("lblMessage"), Label).Text =
value

Method 2:
Viewstate("msg") = value
then in UpdateProgress1_Load event, I put
CType(UpdateProgress1.Controls.FindControl("lblMessage"), Label).Text =
Viewstate("msg")

But both methods are not working! FindControl can't find lblMessage and
return nothing!


Therefore, does anyone know how to access the label lblMessage in
ProgressTemplate of UpdateProgress?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top