Link to home
Start Free TrialLog in
Avatar of Webboy2008
Webboy2008

asked on

asp.net / c# / ajax

I am using aspx/c#/Ajax/AjaxToolKit for the project.
For some reasons, the ajax fresh thing only works when it is first load on the webpage.
later when i tried again. I still see the refresh thing back from the auto post back event.
Any reasons why?

<cc1:ToolkitScriptManager ID="ToolkitScriptManager1"  enablepartialrendering="false" runat="server"></cc1:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
asdfasdfasdfdf
</div>
</ContentTemplate>
Avatar of Member_2_4913559
Member_2_4913559
Flag of United States of America image

No <triggers> defined in your code sample and no postback controls showing in your <contenttemplate> so...?

Any control that causes a postback on your page that is not either inside your <contenttemplate> or setup as a <triggers> is going to cause your page to postback normally(non ajax).
Avatar of Webboy2008
Webboy2008

ASKER

i don't know much about ajax. can you show me how to put those correctly in masterpage?

Thanks,
Nope, but if you post your masterpage with your updatepanel and other relavent code I can take a look at it.
that is all i have. it is just in the beginning.

Thanks
http://msdn.microsoft.com/en-us/library/bb398864.aspx

http://ajax.net-tutorials.com/controls/updatepanel-control/

http://msdn.microsoft.com/en-us/library/bb399001.aspx

http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage2.master.cs" Inherits="MasterPage2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
	</asp:ScriptManager>
    <div>
		<span>Time at Postback:</span>
		<asp:Label ID="postbackLabel" runat="server" /><br />
		<asp:Button ID="BtnSearch" runat="server" Text="Search" 
			onclick="BtnSearch_Click" />
		<asp:UpdatePanel ID="UpdatePnll1" runat="server">
			<ContentTemplate>
				<span>Time on ajax postback:</span>
				<asp:Label ID="displayLabel" runat="server" />
			</ContentTemplate>
			<Triggers>
				<asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
			</Triggers>
		</asp:UpdatePanel>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Open in new window

or on aspx using a masterpage
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage2.master.cs" Inherits="MasterPage2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
	</asp:ScriptManager>
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Open in new window

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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.Xml.Linq;

public partial class MasterPage2 : System.Web.UI.MasterPage
{

}

Open in new window

<%@ Page Language="C#" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
		<span>Time at Postback:</span>
		<asp:Label ID="postbackLabel" runat="server" /><br />
		<asp:Button ID="BtnSearch" runat="server" Text="Search" 
			onclick="BtnSearch_Click" />
		<asp:UpdatePanel ID="UpdatePnll1" runat="server">
			<ContentTemplate>
				<span>Time on ajax postback:</span>
				<asp:Label ID="displayLabel" runat="server" />
			</ContentTemplate>
			<Triggers>
				<asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
			</Triggers>
		</asp:UpdatePanel>
</asp:Content>

Open in new window

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        postbackLabel.Text = DateTime.Now.ToLongTimeString();
    }
    protected void BtnSearch_Click(object sender, EventArgs e)
    {
        displayLabel.Text = DateTime.Now.ToLongTimeString();
    }
}

Open in new window

<asp:UpdatePanel ID="UpdatePnll1" runat="server"></asp> will be on each children page?
It really depends.

I know you are trying to understand and that's commendable but where and how to place this control depends entirely on the context in which you want to use it and the controls you use it with.

I could give you a general answer but you'd be confused. I could give you a specific answer but then it wouldn't work because your situation would be something I didnt know about.

This is something you really need to read up on, test with and then when you have an error you can ask more.

You could try this which may make ajax work on all your pages, but I'm not promising there won't be complications. I just can't know.

<see code>

In this example on the Masterpage I have surrounded the content placeholder (which contains all aspx pages) with an update panel. Now technically any page inside of it that tries to cause a postback will actually trigger an ajax postback.

If you had more than one content placeholder on your masterpage you would have to expand the update panel to surround them all.

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage2.master.cs" Inherits="MasterPage2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
	</asp:ScriptManager>
    <div>
		<asp:UpdatePanel ID="UpdatePnll1" runat="server">
			<ContentTemplate>
				<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
		        
				</asp:ContentPlaceHolder>
			</ContentTemplate>
		</asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Open in new window

s'All I got until you build something, try it out and show me some specific code I'm afraid.
ASKER CERTIFIED SOLUTION
Avatar of Member_2_4913559
Member_2_4913559
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