This is a migrated thread and some comments may be shown as answers.

Inherited Controls can't be updted by child pages??

1 Answer 32 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Sintayehu
Top achievements
Rank 1
Sintayehu asked on 18 Mar 2009, 05:01 PM

I am working on a proj. where I have to get dynamic data. It basically checks for Alerts.

We use polling technology on the server so I set up a static timer in code behind that checkes for the dynamic data every 30sec.

If there are alerts it changes the css of a button to a diffrent button image and displays the alert count.
Simple enough...
Here is the issue:
We have a master page where our navigations live. The Alert button is one of them

our child pages have Ajaxmanagers, and since they inherit from the masterpage I thought I can list the Alert button as part of the updated controls, that way whenever users use one of the ajax controls my Alert button also gets updated. But thats not the case nothing happens.

Therfore:
I tried writting a javascript function that lives on the masterpage, and from code behind I called the javascript function with the response.write() method.

function ChangeAlertButton(styleName, Count){
$find(alertManagerButton.ClientID).className = styleName;
$find(alertManagerButton.ClientID).innerHtml= Count;

or ...

document.getelementbyid(alertManagerButton.ClientID).className = styleName;
document.getelementbyid(alertManagerButton.ClientID).innerHtml= Count;


or...

I even hardcoded the client ID my self but I got an error saying getelementbyid returned null.

}

 

asp

 

:Panel ID="appletAlertManager" runat="server" ToolTip="View and acknowledge AutoMove alerts">

 

 

 

 

 

 

 

<asp:HyperLink runat="server" ID="alertManagerButton" class="alerts button" href="AlertManager.aspx">Alerts &nbsp<asp:Label ID="AlertCount" runat="server"></asp:Label></asp:HyperLink></asp:Panel>

None of this methods worked.

I tried putting another ajaxManager on the master page, I got an error that said I can't have two instances of an ajaxmanager.

That maybe because it doesn't like one in the master and one in child.

Is there a work around.

As I was typing this I figured I try the asp updatepanel and timer and it worked for the most part however as soon as i am on a page that the Alert button refers to the Button disapears, but is fine on all other pages.


    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label1.Text = "UpdatePanel1 refreshed at: " +
          DateTime.Now.ToLongTimeString();
    }

<div>
            <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="10000">
            </asp:Timer>
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="UpdatePanel1 not refreshed yet."></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>

But still I can't figure out why adding a control that is in the master page as an updated control on a child page doesn't work.

Please explain.

Thank you!

 

 

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 23 Mar 2009, 09:58 AM
Hi luay,

Can you confirm that you are setting the ajax settings properly?
Find more about adding ajax settings programmatically here.

Regards,
Iana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Sintayehu
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or