Link to home
Start Free TrialLog in
Avatar of NauticalNonsense
NauticalNonsenseFlag for United States of America

asked on

ASP.NET/Ajax UpdatePanel full page reload issue

Greetings,

I'm having the classic UpdatePanel full page refresh in my main project.

I've set up a brand new ASP.NET Ajax Enabled website, and the sample code I'm using works perfectly.

With the exact same code in my other project, it's not working. When I click GENERATE on my main project, the status bar starts, and causes a full page reload.

Upon looking at the source of the files generated at Page_Load, the main project is not generating the scriprecourse the same, nor the __doPostBack. The first attached code snippet is the one that works, the second one is the one that doesn't.

I have copy/pasted all of the web.config refences from the ASP.NET Ajax website to mine with no difference. I have deleted everything out of the /BIN directory (in case it was getting an older version of Ajax from bin, whereas the ajax enabled has nothing in bin and seems to be getting it from the gac) ...

I'm at wits end, can anyone point me in a direction or take me under their wing to get this working? I've done due diligence with google and here, but have run out of options.

Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
	Untitled Page
</title></head>
<body>
    <form name="form1" method="post" action="default.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE0MjI0NjUwMjdkZGX/UunmkK1+5XZEJ6DFl18+7MY6" />
</div>
 
<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</script>
 
 
<script src="/WebResource.axd?d=yrocR-CaaxzXXqg8aTMfAQ2&amp;t=633301743024531250" type="text/javascript"></script>
 
 
<script src="/ScriptResource.axd?d=eLDBrdhIm9wWDF1L33lJCKNk8SqGoTg6CxHt0xlQNKI1Lc1xSZEg5ePSZbnduZcKo9xqGgkyip1p9054y5JVJ0TRuFmqizbWxTNgQ2x4vFo1&amp;t=633302046090000000" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=eLDBrdhIm9wWDF1L33lJCKNk8SqGoTg6CxHt0xlQNKI1Lc1xSZEg5ePSZbnduZcKo9xqGgkyip1p9054y5JVJ8ahB07fV_66LX1jfVKxiTo1&amp;t=633302046090000000" type="text/javascript"></script>
        <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tupdatePnl'], [], [], 90);
//]]>
</script>
 
        <div>
        
        <div id="updatePnl">
	
            
                <fieldset>
                <legend>Panel with random names</legend>
                <br />
                <input type="submit" name="Button1" value="Generate random names" id="Button1" style="width:200px;" />
                <br />
                <div style="height: 35px; padding-top: 5px; padding-bottom: 5px">
                <div id="UpdateProgress1" style="display:none;">
		
                        <img border="0" src="img/loading.gif" />
                    
	</div>
                </div>
                <span id="lblNames" style="font-weight:bold;"></span>
                <br />
                </fieldset> 
                   
            
</div>
        
        
        </div>
    
<div>
 
	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKXur7wAgKM54rGBv9AqOfJNL15izbDJruHJsNt+Dp8" />
</div>
 
<script type="text/javascript">
<!--
Sys.Application.initialize();
Sys.Application.add_init(function() {
    $create(Sys.UI._UpdateProgress, {"associatedUpdatePanelId":"updatePnl","displayAfter":100,"dynamicLayout":true}, null, null, $get("UpdateProgress1"));
});
// -->
</script>
</form>
</body>
</html>

Open in new window

Avatar of NauticalNonsense
NauticalNonsense
Flag of United States of America image

ASKER

This is what is being generated in the "broken" project:

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
	Untitled Page
</title></head>
<body>
    <form name="form1" method="post" action="testajaxplain.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE0MjI0NjUwMjdkZOf3BngNgmeyMFkPYXZ+NW8gFg/C" />
 
 
<script src="/ScriptResource.axd?d=eLDBrdhIm9wWDF1L33lJCKNk8SqGoTg6CxHt0xlQNKI1Lc1xSZEg5ePSZbnduZcKo9xqGgkyip1p9054y5JVJyCqySRHG_YNt1qNPTgXHyM1&amp;t=633302046090000000" type="text/javascript"></script>
        
        <div>
        
        <div id="updatePnl">
	
            
                <fieldset>
                <legend>Panel with random names</legend>
                <br />
                <input type="submit" name="Button1" value="Generate random names" id="Button1" style="width:200px;" />
                <br />
                <div style="height: 35px; padding-top: 5px; padding-bottom: 5px">
                <div id="UpdateProgress1" style="display:none;">
		
                        <img border="0" src="loading.gif" />
                    
	</div>
                </div>
                <span id="lblNames" style="font-weight:bold;"></span>
                <br />
                </fieldset> 
                   
            
</div>
        
        
        </div>
    
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKuy9DgAgKM54rGBsLtiwmQGfbwNDsC2fbVnTQJbN4C" />
 
<script type="text/javascript">
<!--
Sys.Application.initialize();
// -->
</script>
</form>
</body>
</html>

Open in new window

have you added a script manager?  It should have warned you if not thrown an exception if you haven't but coulld you check?

Andrew
Yes. Both pages are idendical, code in front and code behind follow:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestAjaxPlain.aspx.cs" Inherits="TestAjaxPlain" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
        
        <asp:UpdatePanel ID="updatePnl" runat="server">
            <ContentTemplate>
            
                <fieldset>
                <legend>Panel with random names</legend>
                <br />
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" 
                    Text="Generate random names"
                    Width="200px" />
                <br />
                <div style="height: 35px; padding-top: 5px; padding-bottom: 5px">
                <asp:UpdateProgress ID="UpdateProgress1" runat="server" 
                    AssociatedUpdatePanelID="updatePnl"
                    DisplayAfter="100" DynamicLayout="true">
                    
                    <ProgressTemplate>
                        <img border="0" src="loading.gif" />
                    </ProgressTemplate>
                    
                </asp:UpdateProgress>
                </div>
                <asp:Label Font-Bold=true ID="lblNames" runat="server" Text="">
                </asp:Label>
                <br />
                </fieldset> 
                   
            </ContentTemplate>
        </asp:UpdatePanel>
        
        
        </div>
    </form>
</body>
</html>

Open in new window

and code behind
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
public partial class TestAjaxPlain : System.Web.UI.Page
{
    private readonly string[] NAMES = new string[] { 
    "Mark", "Tom", "Harry", "Sally", "Sandra", "Paul", "Anastasia" };
 
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
 
 
    private void FillListBoxRandom()
    {
        lblNames.Text = "";
 
        List<String> names = new List<string>();
 
        int count = NAMES.Length;
 
        for (int i = 1; i < 30; i++)
        {
            System.Threading.Thread.Sleep(100);
            Random rnd = new Random();
            int number = rnd.Next(count);
            string selName = NAMES[number];
            if (!names.Contains(selName))
            {
                names.Add(selName);
            }
        }
 
        foreach (string name in names)
            lblNames.Text += name + "<BR />";
 
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        FillListBoxRandom();
    }
 
}

Open in new window

Have you got all the required AJAX Elements in your web.config.  Compare you web.config for both projects.

Andrew :-)
I think you may have a Sys is undefined error.  Do you?  Javascript error on the page.

Andrew
I've gopied and pasted the web.config from the working one (well, the relevant sections anyway) to the broken one prior to posting here... There are no "errors" of any kind, javascript or otherwise, just different generation as far as I can tell.

Strangely, in the "broken" project, I'm using an ajax toolkit thing, and it works fine. It's the textbox that goes and gets the matching list of items, so Ajax is working in that broken project, but the non-toolkit and/or updatepanel is messed up somehow.

Thanks for your time, Andrew. Nobody else wants to play.
ASKER CERTIFIED SOLUTION
Avatar of NauticalNonsense
NauticalNonsense
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial