473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

AJAX UpdatePanel PostBack Problem

I have a news section of the website contained within the updatepanel.
What I want is that when a news summary is clicked, the news item
opens up in that same box. I thought I wired everything up correctly
so that it did not do a postback. But when I walked through the
execution process, it in fact does cause a postback when the "expand"
event is raised. Why does this happen? Can someone help me? Thanks.

Here is the .aspx part

1 <%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <atlas:ScriptManager ID="scriptManager" runat="server"></
atlas:ScriptManager>
5 <head>
6 <meta name="author" content="Wink Hosting
(www.winkhosting.com)" />
7 <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
8 <link rel="stylesheet" href="images/style.css" type="text/
css" />
9 <title>Northpoint Data Inc.</title>
10 </head>
11 <body>
12 <form id="form1" runat="server">
13 <div id="page" align="center">
14 <div id="content" style="width:800px">
15 <div id="logo">
16 </div>
17 <div id="topheader">
18 <div align="left" class="bodytext">
19 <br />
20 </div>
21 <div id="toplinks" class="smallgraytext">
22 <a href="#">Home</a| <a
href="#">Sitemap</a| <a href="#">Contact Us</a>
23 </div>
24 </div>
25 <div id="menu">
26 <div align="right" class="smallwhitetext"
style="padding:9px;">
27 <a href="#">Home</a| <a href="#">About
Us</a| <a href="#">Products</a| <a href="#">Our Services</a| <a
href="#">Contact Us</a>
28 </div>
29 </div>
30
31 <div id="contenttext">
32 <div style="padding:10px">
33 <span class="titletext">Welcome to
Northpoint Data!</span>
34 </div>
35 <div class="bodytext" style="padding:
12px;" align="justify">
36 <strong>Hi! This is my third design for
OSWD, with CSS and XHTML 1.0 Transitional Validation. You can do
whatever you want with this template, just keep the Hosting Colombia
link at the bottom. Enjoy! </strong><br />
37 <br />
38 Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.<br /><br />
39 Aenean ut mauris luctus mauris interdum
convallis. Nunc vestibulum sodales nulla. Nulla vitae massa. Maecenas
vel tellus vitae elit mattis adipiscing. In pulvinar felis sed est.
Mauris non mi. Duis ultrices dolor ut orci. Quisque lacinia arcu et
purus. Sed euismod metus nec augue. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Nunc dolor leo,
aliquam a, placerat sit amet, accumsan eget, dolor. Sed lacinia augue
in magna. Fusce sed enim. Vestibulum et mauris. Phasellus in lectus.
Pellentesque eu elit in dolor ullamcorper sodales. Vestibulum interdum
ornare ligula. Mauris felis odio, rhoncus sed, adipiscing fermentum,
tincidunt eu, metus. Suspendisse viverra rhoncus purus.
40 </div>
41 </div>
42 <atlas:UpdatePanel ID="newsUP" runat="server"
Mode="Conditional">
43 <ContentTemplate>
44
45 <div id="leftpanel">
46 <div align="justify"
class="graypanel">
47
48 <asp:Label ID="newz"
runat="server" Visible="false" CssClass="bodytext"></asp:Label>
49 <asp:Panel
ID="defaultPanel" runat="server">
50 <span
class="smalltitle">News</span><br /><br />
51 <span
class="smallredtext">September 27, 2006</span><br />
52 <span
class="bodytext">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
53 <asp:LinkButton
ID="news1" runat="server" CssClass="smallgraytext" OnCommand="expand"
CommandArgument="1" Text="More..."></asp:LinkButton><br /><br />
54 <span
class="smallredtext">September 27, 2006</span><br />
55 <span
class="bodytext">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
56 <asp:LinkButton
ID="news2" runat="server" CssClass="smallgraytext" OnCommand="expand"
CommandArgument="2" Text="More..."></asp:LinkButton><br /><br />
57 <span
class="smallredtext">September 27, 2006</span><br />
58 <span
class="bodytext">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
59 <asp:LinkButton
ID="news3" runat="server" CssClass="smallgraytext" OnCommand="expand"
CommandArgument="3" Text="More..."></asp:LinkButton><br /><br />
60 </asp:Panel>
61 <asp:PlaceHolder
ID="newsP" runat="server">
62 <br />
63 <asp:LinkButton
ID="back" runat="server" CommandArgument="back"
CssClass="smallgraytext" OnCommand="expand" Text="back"
Visible="true"></asp:LinkButton>
64 </asp:PlaceHolder>
65 </div>
66 </div>
67
68 </ContentTemplate>
69 <Triggers>
70 <atlas:ControlEventTrigger
ControlID="news1" EventName="Command" />
71 <atlas:ControlEventTrigger
ControlID="back" EventName="Command" />
72 </Triggers>
73 </atlas:UpdatePanel>
74 <div id="footer" class="smallgraytext">
75 <a href="#">Home</a| <a href="#">About Us</
a| <a href="#">Products</a| <a href="#">Our Services</a| <a
href="#">Contact Us</a>
76 | Northpoint Data Inc.
77 © 2007 | <a href="http://www.winkhosting.com"
target="_blank">Hosting Colombia</a>
78 </div>
79 </div>
80 </div>
81 </form>
82 </body>
83 </html>

Here is the .cs portion

1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Web;
5 using System.Web.Security;
6 using System.Web.UI;
7 using System.Web.UI.WebControls;
8 using System.Web.UI.WebControls.WebParts;
9 using System.Web.UI.HtmlControls;
10
11 public partial class _Default : System.Web.UI.Page
12 {
13 string test = "Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.";
14 protected void Page_Load(object sender, EventArgs e)
15 {
16 }
17
18 protected void expand(object sender, CommandEventArgs e)
19 {
20 if (e.CommandArgument == "1")
21 {
22 newz.Text = test;
23 newz.Visible = true;
24 newsP.Visible = true;
25 defaultPanel.Visible = false;
26 }
27 if (e.CommandArgument == "back")
28 {
29 newz.Visible = false;
30 defaultPanel.Visible = true;
31 newsP.Visible = false;
32 }
33
34 }
35 }

Mar 7 '07 #1
1 2155
the update panel works as follows:

client script

1) read all controls on page a build a standard post name/value pair string
2) send the post data to page via an iframe or XMLHttpRequest

server code
1) do standard page process
2) fire panel event
3) collect the update panel render html only
4) send the html back to the client script

client script
1) receive postback html
2) replace panels innerHTML with postback html
-- bruce (sqlwork.com)

jobo wrote:
I have a news section of the website contained within the updatepanel.
What I want is that when a news summary is clicked, the news item
opens up in that same box. I thought I wired everything up correctly
so that it did not do a postback. But when I walked through the
execution process, it in fact does cause a postback when the "expand"
event is raised. Why does this happen? Can someone help me? Thanks.

Here is the .aspx part

1 <%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <atlas:ScriptManager ID="scriptManager" runat="server"></
atlas:ScriptManager>
5 <head>
6 <meta name="author" content="Wink Hosting
(www.winkhosting.com)" />
7 <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
8 <link rel="stylesheet" href="images/style.css" type="text/
css" />
9 <title>Northpoint Data Inc.</title>
10 </head>
11 <body>
12 <form id="form1" runat="server">
13 <div id="page" align="center">
14 <div id="content" style="width:800px">
15 <div id="logo">
16 </div>
17 <div id="topheader">
18 <div align="left" class="bodytext">
19 <br />
20 </div>
21 <div id="toplinks" class="smallgraytext">
22 <a href="#">Home</a| <a
href="#">Sitemap</a| <a href="#">Contact Us</a>
23 </div>
24 </div>
25 <div id="menu">
26 <div align="right" class="smallwhitetext"
style="padding:9px;">
27 <a href="#">Home</a| <a href="#">About
Us</a| <a href="#">Products</a| <a href="#">Our Services</a| <a
href="#">Contact Us</a>
28 </div>
29 </div>
30
31 <div id="contenttext">
32 <div style="padding:10px">
33 <span class="titletext">Welcome to
Northpoint Data!</span>
34 </div>
35 <div class="bodytext" style="padding:
12px;" align="justify">
36 <strong>Hi! This is my third design for
OSWD, with CSS and XHTML 1.0 Transitional Validation. You can do
whatever you want with this template, just keep the Hosting Colombia
link at the bottom. Enjoy! </strong><br />
37 <br />
38 Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.<br /><br />
39 Aenean ut mauris luctus mauris interdum
convallis. Nunc vestibulum sodales nulla. Nulla vitae massa. Maecenas
vel tellus vitae elit mattis adipiscing. In pulvinar felis sed est.
Mauris non mi. Duis ultrices dolor ut orci. Quisque lacinia arcu et
purus. Sed euismod metus nec augue. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Nunc dolor leo,
aliquam a, placerat sit amet, accumsan eget, dolor. Sed lacinia augue
in magna. Fusce sed enim. Vestibulum et mauris. Phasellus in lectus.
Pellentesque eu elit in dolor ullamcorper sodales. Vestibulum interdum
ornare ligula. Mauris felis odio, rhoncus sed, adipiscing fermentum,
tincidunt eu, metus. Suspendisse viverra rhoncus purus.
40 </div>
41 </div>
42 <atlas:UpdatePanel ID="newsUP" runat="server"
Mode="Conditional">
43 <ContentTemplate>
44
45 <div id="leftpanel">
46 <div align="justify"
class="graypanel">
47
48 <asp:Label ID="newz"
runat="server" Visible="false" CssClass="bodytext"></asp:Label>
49 <asp:Panel
ID="defaultPanel" runat="server">
50 <span
class="smalltitle">News</span><br /><br />
51 <span
class="smallredtext">September 27, 2006</span><br />
52 <span
class="bodytext">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
53 <asp:LinkButton
ID="news1" runat="server" CssClass="smallgraytext" OnCommand="expand"
CommandArgument="1" Text="More..."></asp:LinkButton><br /><br />
54 <span
class="smallredtext">September 27, 2006</span><br />
55 <span
class="bodytext">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
56 <asp:LinkButton
ID="news2" runat="server" CssClass="smallgraytext" OnCommand="expand"
CommandArgument="2" Text="More..."></asp:LinkButton><br /><br />
57 <span
class="smallredtext">September 27, 2006</span><br />
58 <span
class="bodytext">Curabitur arcu tellus, suscipit in, aliquam eget,
ultricies id, sapien. Nam est.</span><br />
59 <asp:LinkButton
ID="news3" runat="server" CssClass="smallgraytext" OnCommand="expand"
CommandArgument="3" Text="More..."></asp:LinkButton><br /><br />
60 </asp:Panel>
61 <asp:PlaceHolder
ID="newsP" runat="server">
62 <br />
63 <asp:LinkButton
ID="back" runat="server" CommandArgument="back"
CssClass="smallgraytext" OnCommand="expand" Text="back"
Visible="true"></asp:LinkButton>
64 </asp:PlaceHolder>
65 </div>
66 </div>
67
68 </ContentTemplate>
69 <Triggers>
70 <atlas:ControlEventTrigger
ControlID="news1" EventName="Command" />
71 <atlas:ControlEventTrigger
ControlID="back" EventName="Command" />
72 </Triggers>
73 </atlas:UpdatePanel>
74 <div id="footer" class="smallgraytext">
75 <a href="#">Home</a| <a href="#">About Us</
a| <a href="#">Products</a| <a href="#">Our Services</a| <a
href="#">Contact Us</a>
76 | Northpoint Data Inc.
77 © 2007 | <a href="http://www.winkhosting.com"
target="_blank">Hosting Colombia</a>
78 </div>
79 </div>
80 </div>
81 </form>
82 </body>
83 </html>

Here is the .cs portion

1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Web;
5 using System.Web.Security;
6 using System.Web.UI;
7 using System.Web.UI.WebControls;
8 using System.Web.UI.WebControls.WebParts;
9 using System.Web.UI.HtmlControls;
10
11 public partial class _Default : System.Web.UI.Page
12 {
13 string test = "Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Curabitur id est tincidunt nisl pellentesque
tincidunt. Donec in mauris. Mauris neque magna, consectetuer id,
malesuada vitae, tincidunt sit amet, mi. Aliquam lacinia.
Suspendisse potenti. Proin justo lorem, rutrum ac, facilisis in,
malesuada sed, ligula. Mauris lobortis lacus at nibh. Aenean vitae
odio vel odio placerat hendrerit. Suspendisse lacus lacus, tempor
id, pharetra eget, ornare sit amet, pede. Sed aliquet, justo ac
elementum pretium, arcu leo placerat est, a luctus purus diam eget
arcu. Nam augue diam, mollis a, scelerisque eget, aliquet
condimentum, pede. Vestibulum tristique lectus sed augue.";
14 protected void Page_Load(object sender, EventArgs e)
15 {
16 }
17
18 protected void expand(object sender, CommandEventArgs e)
19 {
20 if (e.CommandArgument == "1")
21 {
22 newz.Text = test;
23 newz.Visible = true;
24 newsP.Visible = true;
25 defaultPanel.Visible = false;
26 }
27 if (e.CommandArgument == "back")
28 {
29 newz.Visible = false;
30 defaultPanel.Visible = true;
31 newsP.Visible = false;
32 }
33
34 }
35 }
Mar 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brett | last post by:
I have an AJAX updatepanel in an aspx page. Inside the updatepanel is a placeholder control, which loads various ascx files. This all works fine. One of the ascx files also has an updatepanel in...
8
by: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= | last post by:
I am new to AJAX. I am applying AJAX to a current web solution to get the "instant behaviour". On my main page I have two sets of criteria: Specific and Wide. Each set is placed in a View...
6
by: HockeyFan | last post by:
I'd like to have an AJAX textbox that after the user fills in, will auto-fill another textbox on the page without having a postback occur. It doesn't have to do any filtering or any other thing...
7
by: MikeB | last post by:
Hello All, I am new to ajax and wanted to start by trying something simple. I have a web form with an updatepanel and then inside the update panel I have a listbox. Then outside of the updatepanel...
1
by: abellix | last post by:
An updatepanel contains a datagrid, this datagrid has columns generated by code-behind: some columns should have async postback, others should have sync postback. Here a sample to reproduce the...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
1
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped...
6
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered...
3
by: =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post by:
Hello, On a webpage, create an UpdatePanel with two DropDownLists. Set AutoPostBack of DropDownList1 to true. In the SelectedIndexChanged method, refill DropDownList2 and set the focus to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.