470,836 Members | 1,897 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,836 developers. It's quick & easy.

Page Posts Back even when using AJAX

To all,

I'm trying to use ajax in my web site project but everytime I hit the button
on my webform the whole page posts back. The label control that I have in my
update panel does what it is suppose to do without effecting any other
controls outside the panel. Can you guys provide any insight? Please keep
in mind that I'm trying to update an existing website and did not start a
whole new project by using the template called, "ASP.NET AJAX-Enabled Web
Site".

I did create a site using an AJAX enabled web site template and found no
issues with using the same code below. I also tried comparing the
differences of my webform (using the same code below) in my existing web site
project and could not determine difference in code....other than that my
webform in my website project is posting the whole page back.

Here is the codes that I'm using:

HTML:

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="TestingAJAX.aspx.vb" Inherits="TestingAJAX" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>

<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>
<br />
<asp:Label ID="Label1" runat="server" Text="Label"
Width="168px"></asp:Label><br />
<br />
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text="Label"
Width="168px"></asp:Label>
</ContentTemplate>

<triggers>
<asp:AsyncPostBackTrigger ControlID = "button1"
eventname="click" />
</triggers>
</asp:UpdatePanel>
</form>
</body>
</html>

CODE BEHIND:

Partial Class TestingAJAX
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Label1.Text = Date.Now
End If

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label2.Text = Date.Now
End Sub
End Class
Mar 15 '07 #1
0 1239

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Aaron Prohaska | last post: by
9 posts views Thread by paul | last post: by
7 posts views Thread by Schmidty | last post: by
1 post views Thread by Rob | last post: by
reply views Thread by =?Utf-8?B?TGlhbQ==?= | last post: by
8 posts views Thread by Harvey Schmidlapp | last post: by
7 posts views Thread by Microsoft Newsserver | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.