Still Unable To Get UpdatePanel control to function properly

hversemann

Member
Joined
Jul 29, 2016
Messages
11
Location
midwest
Programming Experience
3-5
In the web App. that I'm developing I have several content pages of which only one of them is using an UpdatePanel control. My ScriptManager control is on the master page of the app. but after some reading I'm not sure its in the right place. I've placed it within the FORM tag underneath the BODY tag on my master page and not presently in either of the two content holder controls on the master page, but I have yet to get this to work even once. So here are all the pieces from the master page through the content page:

1.) MasterPage code:
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" SupportsPartialRendering="true" >

2.) Current content page markup code:

<asp:Button ID="UpdatePanelButton" runat="server" Text="Update Panel" Visible="false" OnClick="UpdatePanelButton_Click" />
<asp:UpdatePanel ID="PullRubricPageUpdatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<br />
<asp:Label ID="UpdatePanelLabel" runat="server" Text="" Font-Bold="true" ForeColor="#ff0066"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdatePanelButton" EventName="Click" ></asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>

3.) In my actual code-behind method DisplayUpdatePanelLabelMessage(string msg, string caller) is called with the following code in it:

if ((msg != null) && (msg != "") && (msg != " "))
{
updtMessage = msg;
UpdatePanelButton_Click(new object(), new EventArgs());
}



4.) And then finally the UpdatePanelButton_Click method is called and its code looks like this:

Label UpdatePanelLabel = (Label)PullRubricPageUpdatePanel.FindControl("UpdatePanelLabel");
UpdatePanelLabel.Text = updtMessage;


So I would normally expect the label to update asynchronously and frequently during a couple of different parts of the logic, but it only seems to update synchronously, so I'm missing something somewhere in the setup of the whole UpdatePanel process. But what?

I have actually put breakpoints in my code in both the DisplayUpdatePanelLabelMessage method and the UpdatePanelButton_Click method and messages are being sent to both of them, yet nothing is happening asynchronously on the page within the UpdatePanel.

So any help in figuring out my problem would be greatly appreciated.

Thanks for the help.

Henry
 
I haven't used Web Forms for a long time and I didn't use it much then, plus I've never used an UpdatePanel. That said, your code does not look right to me. In the code-behind, you specify that the UpdatePanel posts on a click of UpdatePanelButton. You seem to be under the impression that directly calling the method that handles that event should result in a postback. It should not. Calling an event handling method does not mean that the event it handles has been raised. You would have to actually click the Button for that to happen. You can presumably do that in script but you can't do it in code-behind. I can't tell you what you need to do to achieve your aim but I can tell you that you're barking up the wrong tree there. You need to understand the difference between an event and an event handler.
 
I understand what you're saying, and since I made the first post below I have changed my code a bit.
Now inside the update panel I'm using a textbox control which is supposed to fire a "TextChanged" event which "[FONT=&quot]Occurs when the content of the text box changes between posts to the server.[/FONT]" to quote some documentation that I found. So since the textbox is inside the update panel it is supposed to by default cause the panel to be updated. Now in several locations throughout the rest of the code for this problem page I'm calling a method with a message to be displayed in a label in my update panel. In that method I'm setting a new text value in the .Text property of the textbox in my update panel. so when I do that shouldn't the "TextChanged" event fire and call its related event handler? If so then something else must be wrong, unless I have one or more of the assumptions that I've made here wrong. I have even tried at the top of my Page_Load event handler for the page to register the textbox control in the update panel with the script manager from my master page like this:

ScriptManager ScriptManager1 = (ScriptManager)Page.Master.FindControl("ScriptManager1");
ScriptManager1.RegisterAsyncPostBackControl(PullRubricHiddenTextBox);

and still no updates seem to be happening with my update panel.

So are any of my assumptions above wrong as to how things should work?

If so please correct me. This is the first time I've really tried to use an update panel on any page.

Thanks for the help.

Henry
 
Back
Top Bottom