Home > Mobile >  control in update panel not firing
control in update panel not firing

Time:10-11

I have two almost identical page in my application. On one page the control fires properly and updates the text box using a partial render. On the other page the changing the text in the control does nothing. If I add a trigger tag in that update panel the control fires but it refreshes the entire page. I'm trying to utilize the partial render so the page does not flicker.

Both pages use the same site.master which contains the the script manager tag:

<asp:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server">

The markup for the update panel is as follows:

<td> 
     <asp:UpdatePanel runat="server" ID="UpdatePanel1">
          <ContentTemplate> 
            &nbsp;<asp:TextBox ID="weight" runat="server" BackColor="#FFFF99" TextMode="Number" AutoPostBack="True" ValidateRequestMode="Disabled" Width="53px" AccessKey="G" CausesValidation="True"></asp:TextBox>
           <br />&nbsp;<asp:TextBox ID="size" runat="server" Width="81px" BackColor="#DAFCF4" AccessKey="G"></asp:TextBox>
          </ContentTemplate>
     </asp:UpdatePanel>

</td>

                    

The code behind is the same on both pages. Any suggestions?

Thanks Nor

CodePudding user response:

I seen this issue crop up for a VERY long time.

The suggestions include:

Double check you have autopostback=true for the text box.

Try changing the UP to using update mode conditional.

Eg this:

        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:TextBox ID="TextBox1" runat="server"
                    AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"
                    ClientIDMode="AutoID"> 
                </asp:TextBox>

                <asp:CheckBox ID="CheckBox2" runat="server" />
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="TextBox1" EventName="TextChanged" />
            </Triggers>
        </asp:UpdatePanel>

And last but not least, try adding clientidmode="auto" to the text box.

I'm open to more ideas, but try above.

You could also check if you using/have jQuery added to the page, as that might be another long shot.

And last but not least, try adding a trigger - triggers SHOULD NOT be required for any button, or quite much ANY event for any control that has a or will post back.

        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:TextBox ID="TextBox1" runat="server"
                    AutoPostBack="true" OnTextChanged="TextBox1_TextChanged">

                </asp:TextBox>
                <asp:CheckBox ID="CheckBox2" runat="server" />
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="TextBox1" EventName="TextChanged" />
            </Triggers>
        </asp:UpdatePanel>

If after all above was done, then last huge and beyond silly having to do would be to add some JavaScript to the Textbox, and have that that js code click a hidden button in the UP.

However, this issue has come up time and time again in the last 15 or even now close to 20 years, and despite a boatload of suggesting, I did not find ANY clear or ANY solid solution to this issue.

I would be somewhat comfortable stating this is a asp.net bug, and one that been around for about 20 years without a valid solution.

One solution and suggestion stated to change the clientid mode of the TextBox to AutoID, so this:

<asp:TextBox ID="TextBox1" runat="server"
    AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"
    ClientIDMode="AutoID"  > 
</asp:TextBox>

I can't say the above worked for me, but like you, I am open to any particular suggestion, and over the 20 years, I not found nor seen, nor was able to provide a working solution to this issue - my solution was to resort to using JavaScript to fire a hidden button also inside of the UP to correctly trigger the post-back.

this issue ONLY seems to crop up in regard to a textbox changed event, for buttons, for check box, for dropdown list, even radibutton list? Or just about anything else, the UP works fine!!!!

However, for some strange reason, the TextBox with autopostback=true and a event code stub behind, this issue been around for a long time, and I did not find any suggesting's that are a solid solution.

So, check/try the several ideas above - come back and tell us if any worked. If none worked, then we have to resort to some JavaScript code, and a hidden button that the JavaScript code can click for us by using client-side JavaScript code to trigger the post-back correctly here.

CodePudding user response:

Hey thanks for all that info.What I had done was use one page (the one that works properly) as template. Copied it and the code behind and then made some change to the new page. Somewhere along that line I must have change something that the system didn't like. SO I went back to the drawing board and redid the copy but this time made minimal change to the page retaining the additional functionality that I wanted and the thing works like a charm. Can't say why. I spent some time comparing the markup of the new page that works with the one that didn't and couldn't fine anything obvious that would screw up the process.

Again I thank you for you reply and will keep this info on hand.

Cheers Nor

  • Related