Hi, i am having a problem with my AjaxRequest method that i have hooked up to the onchange event of a dynamically created button. It seems to work fine in that the server side method fires and calls a method I have for calculationg a count. The problem is that i update a client side label with this count but the label on the page does not get updated. The weird thing is that on the same page I have a button that calls the same server side method which updates the label correctly as you would expect. Can anyone see how i am going wrong or why the label is not getting updated?
this is my javascript:
this is my ajax manager code that contains the reference to the serverside onajaxrequest method and also the panel that is being refreshed via the button click:
this is the ajaxified button and the label to be refreshed
this is where i am dynamically building my textbox(s)
and this is the server side method that is called when I click the button directly and also the onajaxrequest method that calls the same method:
on both events the "lblNumberPresent.Text = "Total number of students present = " + intCount;"
line is hit in the debugger but it is only on the button click that the label on the page gets updated...
this is my javascript:
| function InitiateAjaxRequest(arguments) |
| { |
| var ajaxManager = <%= RadAjaxManager1.ClientID %>; |
| ajaxManager.AjaxRequest(arguments); |
| } |
| <rad:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" > |
| <AjaxSettings> |
| <rad:AjaxSetting AjaxControlID="RadAjaxManager1"> |
| </rad:AjaxSetting> |
| <rad:AjaxSetting AjaxControlID="pnlNumberPresent"> |
| <UpdatedControls> |
| <rad:AjaxUpdatedControl ControlID="pnlNumberPresent" /> |
| </UpdatedControls> |
| </rad:AjaxSetting> |
| </AjaxSettings> |
| </rad:RadAjaxManager> |
this is the ajaxified button and the label to be refreshed
| <asp:Panel ID="pnlNumberPresent" CssClass="row" runat="server" Visible="True" > |
| <asp:Label id="lblNumberPresent" runat="server" Visible="true" Cssclass="field_label_noclear" /> |
| <asp:Button id="btnRefreshNumberPresent" Cssclass="input_but" text="Refresh" runat ="server" OnClick="calculateNumberPresent" /> |
| </asp:Panel> |
this is where i am dynamically building my textbox(s)
| if (bJavaScriptEnabled) |
| { |
| int nextTextboxNo = StudentCount + 1; |
| statusBox.Attributes.Add("onchange", "InitiateAjaxRequest(this,event); return false;"); |
| statusBox.Attributes.Add("onkeypress", "setFocusOnEnterKey('status_textbox_" + nextTextboxNo.ToString() + "',event);"); |
| } |
and this is the server side method that is called when I click the button directly and also the onajaxrequest method that calls the same method:
| protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
| { |
| calculateNumberPresent(sender, e); |
| } |
| protected void calculateNumberPresent(object sender, EventArgs e) |
| { |
| int intCount = 0; |
| //code to do count here... |
| lblNumberPresent.Text = "Total number of students present = " + intCount; |
| } |
on both events the "lblNumberPresent.Text = "Total number of students present = " + intCount;"
line is hit in the debugger but it is only on the button click that the label on the page gets updated...